#include <mn_convar.hpp>
Public Member Functions | |
basic_condition_variable () | |
void | signal () |
void | broadcast () |
void | notify_one () noexcept |
void | notify_all () noexcept |
Protected Attributes | |
mutex_t | m_mutex |
std::list< basic_convar_task * > | m_waitList |
Private Member Functions | |
void | add_list (basic_convar_task *thread) |
Friends | |
class | basic_convar_task |
Detailed Description
Class implementation of condition variable
A condition variable isn't really a variable. It's a list of threads.
The design here is that a basic_convar_task "waits", and a condition_variable "signals". This affects where the public interfaces reside.
Constructor & Destructor Documentation
◆ basic_condition_variable()
mn::ext::basic_condition_variable::basic_condition_variable | ( | ) |
Constructor to create a condition variable.
Member Function Documentation
◆ add_list()
|
private |
Internal helper function to queue a basic_convar_task to this condition_variable's wait list.
- Parameters
-
thread The basic_convar_task to add to the waiting list
◆ broadcast()
void mn::ext::basic_condition_variable::broadcast | ( | ) |
Signal all threads waiting on this condition_variable.
◆ notify_all()
|
inlinenoexcept |
◆ notify_one()
|
inlinenoexcept |
◆ signal()
void mn::ext::basic_condition_variable::signal | ( | ) |
Signal a thread waiting on this condition_variable (FIFO list).
Friends And Related Function Documentation
◆ basic_convar_task
|
friend |
The basic_convar_task class and the basic_condition_variable class are interdependent. If we allow the basic_convar_task class to access the internals of the basic_condition_variable, we can reduce the public interface which is a good thing.
Member Data Documentation
◆ m_mutex
|
protected |
Protect the internal condition_variable state.
◆ m_waitList
|
protected |
Implementation of a wait list of Threads.
The documentation for this class was generated from the following files: