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

Base class for all named synchronization objects. More...

#include <syncbase.h>

Inheritance diagram for mlib::syncbase:
mlib::event mlib::mutex mlib::semaphore mlib::thread mlib::wtimer mlib::auto_event mlib::manual_event mlib::http_connection mlib::tcpserver mlib::httpd

Public Member Functions

 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.
 

Protected Member Functions

 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

Base class for all named synchronization objects.

The Windows handle has an instance counter so copying and assignment are safe and rather cheap (doesn't call DuplicateHandle).

The virtual bool conversion operator allows testing the signaled state of the object (it is true if object is signaled).

Member Function Documentation

◆ is_signaled()

bool mlib::syncbase::is_signaled ( )
inlinevirtual

Try to wait on the object.

Returns true if the object was in a signaled state.

Reimplemented in mlib::auto_event.

◆ name() [1/2]

virtual const std::string & mlib::syncbase::name ( ) const
inlinevirtual

Return object's name.

Reimplemented in mlib::thread.

◆ name() [2/2]

void mlib::syncbase::name ( const std::string & nam)
inlineprotectedvirtual

Change object's name.

Reimplemented in mlib::thread.

◆ wait() [1/2]

DWORD mlib::syncbase::wait ( DWORD limit_msec)
inlinevirtual

Wait a number of milliseconds for the object to become signaled.

Parameters
limit_msecmaximum wait time in milliseconds
Returns
WAIT_OBJECT0 if object becomes signaled
WAIT_TIMEOUT if timeout has expired

Reimplemented in mlib::thread.

◆ wait() [2/2]

DWORD mlib::syncbase::wait ( std::chrono::milliseconds limit)
inlinevirtual

Wait a number of milliseconds for the object to become signaled.

Parameters
limitmaximum wait time
Returns
WAIT_OBJECT0 if object becomes signaled
WAIT_TIMEOUT if timeout has expired

◆ wait_alertable()

DWORD mlib::syncbase::wait_alertable ( DWORD limit_msec = INFINITE)
inlinevirtual

Wait for object to become signaled or an APC or IO completion routine to occur

Reimplemented in mlib::thread.

◆ wait_msg()

DWORD mlib::syncbase::wait_msg ( DWORD limit_msec = INFINITE,
DWORD mask = QS_ALLINPUT )
inlinevirtual

Wait for object to become signaled or a message to be queued.

Parameters
limit_msectime-out interval, in milliseconds
maskinput message types
Returns
WAIT_OBJECT_0 thread finished
WAIT_TIMEOUT time-out interval expired
WAIT_OBJECT_0+1 Input message received.

The mask parameter can be any combination of flags described for the GetQueueStatus function.

Reimplemented in mlib::thread.


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