mutex_unify - Melnytskyi/fast_task GitHub Wiki
Declaration
struct mutex_unify {
union {
std::mutex* nmut = nullptr;
std::timed_mutex* ntimed;
std::recursive_mutex* nrec;
task_mutex* umut;
task_rw_mutex* urwmut;
task_recursive_mutex* urmut;
struct multiply_mutex* mmut;
};
mutex_unify();
mutex_unify(const mutex_unify& mut);
mutex_unify(std::mutex& smut);
mutex_unify(std::timed_mutex& smut);
mutex_unify(std::recursive_mutex& smut);
mutex_unify(task_mutex& smut);
mutex_unify(task_rw_mutex& smut, bool read_write = true);
mutex_unify(task_recursive_mutex& smut);
mutex_unify(struct multiply_mutex& mmut);
mutex_unify(nullptr_t);
~mutex_unify();
mutex_unify& operator=(const mutex_unify& mut);
mutex_unify& operator=(std::mutex& smut);
mutex_unify& operator=(std::timed_mutex& smut);
mutex_unify& operator=(std::recursive_mutex& smut);
mutex_unify& operator=(task_mutex& smut);
mutex_unify& operator=(task_recursive_mutex& smut);
mutex_unify& operator=(struct multiply_mutex& mmut);
mutex_unify& operator=(nullptr_t);
mutex_unify_type type;
void lock();
bool try_lock();
bool try_lock_for(size_t milliseconds);
bool try_lock_until(std::chrono::high_resolution_clock::time_point time_point);
void unlock();
void relock_start();
void relock_end();
operator bool();
};
This struct is used to unify standard and custom mutexes into one class, allowing them to be handled as a single object.
Usage
fast_task::task_condition_variable cd;
//...
std::mutex some_mutex;
fast_task::mutex_unify hold(some_mutex);
cd.wait(hold);