MLIB
Loading...
Searching...
No Matches
mlib::semaphore Class Reference

Wrapper for Windows semaphore objects. More...

Inheritance diagram for mlib::semaphore:
mlib::syncbase

Public Member Functions

 semaphore (int limit=INT_MAX, const std::string &name=std::string())
 
int signal (int count=1)
 Signal a semaphore object.
 
 operator bool ()
 Test if semaphore is signaled.
 
- Public Member Functions inherited from mlib::syncbase
 syncbase ()
 Default constructor.
 
 syncbase (const syncbase &e)
 Copy constructor.
 
 syncbase (syncbase &&e) noexcept
 Move constructor.
 
virtual ~syncbase ()
 Destructor.
 
syncbaseoperator= (const syncbase &rhs)
 Assignment operator.
 
syncbaseoperator= (syncbase &&rhs) noexcept
 Move assignment operator.
 
int operator== (const syncbase &rhs) const
 Equality operator.
 
virtual void wait ()
 Wait for object to become signaled.
 
virtual DWORD wait (DWORD limit_msec)
 Wait a number of milliseconds for the object to become signaled.
 
virtual DWORD wait (std::chrono::milliseconds limit)
 Wait a number of milliseconds for the object to become signaled.
 
virtual DWORD wait_alertable (DWORD limit_msec=INFINITE)
 
virtual DWORD wait_msg (DWORD limit_msec=INFINITE, DWORD mask=QS_ALLINPUT)
 Wait for object to become signaled or a message to be queued.
 
 operator bool ()
 Check if object is signaled.
 
virtual bool is_signaled ()
 Try to wait on the object.
 
HANDLE handle () const
 Return OS handle of this object.
 
virtual const std::string & name () const
 Return object's name.
 

Additional Inherited Members

- Protected Member Functions inherited from mlib::syncbase
 syncbase (const std::string &name)
 Protected constructor.
 
void set_handle (HANDLE h)
 Change object's handle. Closes the previous one.
 
virtual void name (const std::string &nam)
 Change object's name.
 

Detailed Description

Wrapper for Windows semaphore objects.

A semaphore is a counter incremented by signal and decremented by wait. If counter is negative any waiting thread is blocked until counter becomes positive.

Constructor & Destructor Documentation

◆ semaphore()

mlib::semaphore::semaphore ( int  limit = INT_MAX,
const std::string &  name = std::string () 
)
Parameters
limitmaximum limit for counter
nameobject's name

The documentation for this class was generated from the following files: