sjef
Loading...
Searching...
No Matches
__w
sjef
sjef
src
sjef
util
Locker.h
Go to the documentation of this file.
1
#ifndef SJEF_LIB_LOCKER_H_
2
#define SJEF_LIB_LOCKER_H_
3
#define BOOST_ALL_NO_LIB
4
#include <filesystem>
5
#include <map>
6
#include <mutex>
7
#include <string>
8
#include <thread>
9
namespace
fs = std::filesystem;
10
11
namespace
boost::interprocess
{
12
class
file_lock;
13
}
14
15
namespace
sjef::util
{
29
class
Locker
{
30
public
:
31
explicit
Locker
(fs::path
path
);
32
virtual
~Locker
();
33
const
fs::path&
path
()
const
{
return
m_path; }
34
35
void
add_bolt
();
36
void
remove_bolt
();
37
38
private
:
39
const
fs::path m_path;
40
std::unique_ptr<std::scoped_lock<std::mutex>> m_lock;
41
std::mutex m_mutex;
42
int
m_bolts = 0;
43
const
std::unique_ptr<boost::interprocess::file_lock> m_file_lock;
44
std::thread::id m_owning_thread;
45
46
public
:
47
// RAII
48
struct
Bolt
{
49
explicit
Bolt
(
Locker
& locker);
50
~Bolt
();
51
Bolt
() =
delete
;
52
Bolt
(
const
Bolt
&) =
delete
;
53
Bolt
&
operator=
(
const
Bolt
&) =
delete
;
54
55
private
:
56
Locker
& m_locker;
57
};
58
Bolt
bolt
();
59
};
60
61
}
// namespace sjef::util
62
#endif
// SJEF_LIB_LOCKER_H_
sjef::util::Locker
A thread-safe class for an inter-thread/inter-process lock. The lock mechanism is based on a locked f...
Definition
Locker.h:29
sjef::util::Locker::~Locker
virtual ~Locker()
sjef::util::Locker::path
const fs::path & path() const
Definition
Locker.h:33
sjef::util::Locker::bolt
Bolt bolt()
sjef::util::Locker::remove_bolt
void remove_bolt()
sjef::util::Locker::Locker
Locker(fs::path path)
sjef::util::Locker::add_bolt
void add_bolt()
boost::interprocess
Definition
Locker.h:11
sjef::util
Definition
sjef.h:26
sjef::util::Locker::Bolt
Definition
Locker.h:48
sjef::util::Locker::Bolt::Bolt
Bolt(const Bolt &)=delete
sjef::util::Locker::Bolt::operator=
Bolt & operator=(const Bolt &)=delete
sjef::util::Locker::Bolt::Bolt
Bolt(Locker &locker)
sjef::util::Locker::Bolt::~Bolt
~Bolt()
sjef::util::Locker::Bolt::Bolt
Bolt()=delete
Generated on Thu Jun 25 2026 19:17:15 for sjef by
1.9.8