VOX
A little voxel engine
Loading...
Searching...
No Matches
Status.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <thread>
4#include <mutex>
5#include <condition_variable>
6#include "define.hpp"
7#include "logger.hpp"
8
9class Status
10{
11public:
12 Status();
13 ~Status();
14 Status(const Status & other);
15 Status & operator=(const Status & other);
16 Status(Status && other);
17 Status & operator=(Status && other);
18
23 void lock_shared();
24
31 bool try_lock_shared();
32
36 void unlock_shared();
37
42 void lock();
43
50 bool try_lock();
51
55 void unlock();
56
57 bool isLocked() const;
58 bool isShareLocked() const;
59 bool isLockable() const;
60 bool isShareLockable() const;
61
62private:
63 int m_writer;
64 int m_readers;
65 mutable std::mutex m_mutex ;
66 std::condition_variable m_cv;
67};
Definition: Status.hpp:10
Status & operator=(const Status &other)
Definition: Status.cpp:20
~Status()
Definition: Status.cpp:9
void lock()
adds a writer to the status
Definition: Status.cpp:68
bool try_lock_shared()
Tries to add a reader to the status, will NOT block.
Definition: Status.cpp:47
bool isShareLockable() const
Definition: Status.cpp:113
bool isShareLocked() const
Definition: Status.cpp:101
void lock_shared()
adds a reader to the status
Definition: Status.cpp:40
Status()
Definition: Status.cpp:3
bool isLocked() const
Definition: Status.cpp:95
bool try_lock()
Tries to add a writer to the status, will NOT block.
Definition: Status.cpp:75
bool isLockable() const
Definition: Status.cpp:107
void unlock()
removes a writer from the status
Definition: Status.cpp:86
void unlock_shared()
removes a reader from the status
Definition: Status.cpp:58