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
#include <filesystem>
4
#include <map>
5
#include <mutex>
6
#include <string>
7
#include <thread>
8
namespace
fs = std::filesystem;
9
10
namespace
boost::interprocess
{
11
class
file_lock;
12
}
13
14
namespace
sjef::util
{
28
class
Locker
{
29
public
:
30
explicit
Locker
(fs::path
path
);
31
virtual
~Locker
();
32
const
fs::path&
path
()
const
{
return
m_path; }
33
34
void
add_bolt
();
35
void
remove_bolt
();
36
37
private
:
38
const
fs::path m_path;
39
std::unique_ptr<std::scoped_lock<std::mutex>> m_lock;
40
std::mutex m_mutex;
41
int
m_bolts = 0;
42
const
std::unique_ptr<boost::interprocess::file_lock> m_file_lock;
43
std::thread::id m_owning_thread;
44
45
public
:
46
// RAII
47
struct
Bolt
{
48
explicit
Bolt
(
Locker
& locker);
49
~Bolt
();
50
Bolt
() =
delete
;
51
Bolt
(
const
Bolt
&) =
delete
;
52
Bolt
&
operator=
(
const
Bolt
&) =
delete
;
53
54
private
:
55
Locker
& m_locker;
56
};
57
Bolt
bolt
();
58
};
59
60
}
// namespace sjef::util
61
#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:28
sjef::util::Locker::~Locker
virtual ~Locker()
sjef::util::Locker::path
const fs::path & path() const
Definition
Locker.h:32
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:10
sjef::util
Definition
sjef.h:26
sjef::util::Locker::Bolt
Definition
Locker.h:47
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 Mon Feb 23 2026 18:12:01 for sjef by
1.9.8