MLIB
Loading...
Searching...
No Matches
Synchronization Objects

Wrapper classes for Windows synchronization mechanisms. More...

Data Structures

class  mlib::current_thread
 Currently executing thread object. More...
 
class  mlib::criticalsection
 Lightweight inter-thread synchronization. More...
 
class  mlib::lock
 Automatic wrapper for critical sections. More...
 
class  mlib::event
 Events have only two states: signaled and not signaled. More...
 
class  mlib::mutex
 Wrapper for Windows mutexes. More...
 
class  mlib::semaphore
 Wrapper for Windows semaphore objects. More...
 
class  mlib::syncbase
 Base class for all named synchronization objects. More...
 
class  mlib::thread
 Wrapper for a Windows thread. More...
 
class  mlib::wtimer
 Waitable timer. More...
 
template<typename T >
DWORD mlib::wait_all (const T *objs, int count, DWORD msec=INFINITE)
 Wait for multiple objects until all become signaled.
 
template<typename T >
DWORD mlib::wait_all (std::initializer_list< const T * > objs, DWORD msec=INFINITE)
 Wait for multiple objects until all become signaled.
 
template<typename T >
DWORD mlib::wait_all (std::initializer_list< const T * > objs, std::chrono::milliseconds limit)
 Wait for multiple objects until all become signaled.
 
template<typename T >
DWORD mlib::wait_any (const T *objs, int count, DWORD msec=INFINITE)
 Wait for multiple objects until any of them becomes signaled.
 
template<typename T >
DWORD mlib::wait_any (std::initializer_list< const T * > objs, DWORD msec=INFINITE)
 Wait for multiple objects until any of them becomes signaled.
 
template<typename T >
DWORD mlib::wait_any (std::initializer_list< const T * > objs, std::chrono::milliseconds timeout)
 Wait for multiple objects until any of them becomes signaled.
 
template<typename T >
DWORD mlib::wait_msg (const T *objs, int count, bool all=true, DWORD msec=INFINITE, DWORD mask=QS_ALLINPUT)
 Wait for multiple objects or a message to be queued.
 
template<typename T >
DWORD mlib::wait_msg (std::initializer_list< const T * > objs, bool all=true, DWORD msec=INFINITE, DWORD mask=QS_ALLINPUT)
 Wait for multiple objects or a message to be queued.
 

Detailed Description

Wrapper classes for Windows synchronization mechanisms.

While, currently, most of these objects have standard conforming replacements (std::mutex, std::semaphore, std::thread, etc.) there are still use cases where standard versions lack functionality compared to objects in this library.

One such case is when trying to achieve synchronization between different processes. Standard objects have no (portable) mechanism for sharing them between processes. Other limitations include wakeup on message received (syncbase::wait_alertable) and many limitations related to mlib::thread objects.

Function Documentation

◆ wait_all() [1/3]

template<typename T >
DWORD mlib::wait_all ( const T *  objs,
int  count,
DWORD  msec = INFINITE 
)
inline

Wait for multiple objects until all become signaled.

Wrapper for WaitForMultipleObjects Windows API function.

Parameters
objsarray of objects to wait for
countnumber of objects in array
msectime limit (in milliseconds)

◆ wait_all() [2/3]

template<typename T >
DWORD mlib::wait_all ( std::initializer_list< const T * >  objs,
DWORD  msec = INFINITE 
)
inline

Wait for multiple objects until all become signaled.

Wrapper for WaitForMultipleObjects Windows API function.

Parameters
objsobjects to wait for
msectime limit (in milliseconds)

◆ wait_all() [3/3]

template<typename T >
DWORD mlib::wait_all ( std::initializer_list< const T * >  objs,
std::chrono::milliseconds  limit 
)
inline

Wait for multiple objects until all become signaled.

Wrapper for WaitForMultipleObjects Windows API function.

Parameters
objsobjects to wait for
limittime limit in milliseconds

◆ wait_any() [1/3]

template<typename T >
DWORD mlib::wait_any ( const T *  objs,
int  count,
DWORD  msec = INFINITE 
)
inline

Wait for multiple objects until any of them becomes signaled.

Wrapper for WaitForMultipleObjects Windows API function.

Parameters
objsarray of objects to wait for
countnumber of objects in array
msectimeout interval (in milliseconds)

◆ wait_any() [2/3]

template<typename T >
DWORD mlib::wait_any ( std::initializer_list< const T * >  objs,
DWORD  msec = INFINITE 
)
inline

Wait for multiple objects until any of them becomes signaled.

Wrapper for WaitForMultipleObjects Windows API function.

Parameters
objsobjects to wait for
msectimeout interval (in milliseconds)

◆ wait_any() [3/3]

template<typename T >
DWORD mlib::wait_any ( std::initializer_list< const T * >  objs,
std::chrono::milliseconds  timeout 
)
inline

Wait for multiple objects until any of them becomes signaled.

Wrapper for WaitForMultipleObjects Windows API function.

Parameters
objsobjects to wait for
timeouttimeout interval

◆ wait_msg() [1/2]

template<typename T >
DWORD mlib::wait_msg ( const T *  objs,
int  count,
bool  all = true,
DWORD  msec = INFINITE,
DWORD  mask = QS_ALLINPUT 
)
inline

Wait for multiple objects or a message to be queued.

Wrapper for MsgWaitForMultipleObjects Windows API function.

Parameters
objsarray of objects to wait for
countnumber of objects in array
allif true, wait for all objects to become signaled
msectimeout interval (in milliseconds)
maskmessage mask (combination of QS_... constants)

◆ wait_msg() [2/2]

template<typename T >
DWORD mlib::wait_msg ( std::initializer_list< const T * >  objs,
bool  all = true,
DWORD  msec = INFINITE,
DWORD  mask = QS_ALLINPUT 
)
inline

Wait for multiple objects or a message to be queued.

Wrapper for MsgWaitForMultipleObjects Windows API function.

Parameters
objsobjects to wait for
allif true, wait for all objects to become signaled
msectimeout interval (in milliseconds)
maskmessage mask (combination of QS_... constants)