uLib  User mode C/C++ extended API library for Win32 programmers.
TSyncObj Class Reference

#include <uLib/SyncObj.h>

Inheritance diagram for TSyncObj:
TEvent TMutex TSemaphore TWaitTimer

Detailed Description

Generic base class for waitable objects.

The wait functions (except RegisterWait()) return true for WAIT_OBJECT_0.
If they return false, you can get the wait result with GetLastError().

Note: You should never use INFINITE in Release builds when waiting
on whatever it may be, since you may easily end up with a dangling thread.
Always use a reasonable interval to check if termination conditions have been set.

Definition at line 74 of file SyncObj.h.

Public Functions

 TSyncObj ()
 
 TSyncObj (const HANDLE &Src)
 
 ~TSyncObj ()
 
bool Close ()
 
bool Wait (DWORD msWait)
 
bool WaitEx (DWORD msWait, bool Alertable)
 
bool SignalAndWait (HANDLE hWaitFor, DWORD msWait, bool Alertable)
 
HANDLE RegisterWait (WAITORTIMERCALLBACK Callback, PVOID Context, DWORD msWait, DWORD Flags)
 
bool UnregisterWait (HANDLE hWait)
 
 operator HANDLE ()
 
HANDLE GetHandle ()
 
bool Initialized ()
 
HANDLE Duplicate (HANDLE TargetProc, bool Inherit, ACCESS_MASK Access=0, DWORD Opt=DUPLICATE_SAME_ACCESS)
 

Protected Attributes

HANDLE _hSync
 

Constructor & Destructor Documentation

◆ TSyncObj() [1/2]

TSyncObj::TSyncObj ( )

Definition at line 123 of file SyncObj.cpp.

◆ TSyncObj() [2/2]

TSyncObj::TSyncObj ( const HANDLE &  Src)

Definition at line 127 of file SyncObj.cpp.

◆ ~TSyncObj()

TSyncObj::~TSyncObj ( )

Definition at line 131 of file SyncObj.cpp.

Member Function Documentation

◆ Close()

bool TSyncObj::Close ( )

Definition at line 136 of file SyncObj.cpp.

◆ Wait()

bool TSyncObj::Wait ( DWORD  msWait)

See [MSDN] WaitForSingleObject().

Definition at line 153 of file SyncObj.cpp.

◆ WaitEx()

bool TSyncObj::WaitEx ( DWORD  msWait,
bool  Alertable 
)

See [MSDN] WaitForSingleObjectEx().

Definition at line 165 of file SyncObj.cpp.

◆ SignalAndWait()

bool TSyncObj::SignalAndWait ( HANDLE  hWaitFor,
DWORD  msWait,
bool  Alertable 
)

See [MSDN] SignalObjectAndWait().

Definition at line 177 of file SyncObj.cpp.

◆ RegisterWait()

HANDLE TSyncObj::RegisterWait ( WAITORTIMERCALLBACK  Callback,
PVOID  Context,
DWORD  msWait,
DWORD  Flags 
)

See [MSDN] RegisterWaitForSingleObject().
Returns a wait handle, or NULL on failure.

Definition at line 189 of file SyncObj.cpp.

◆ UnregisterWait()

bool TSyncObj::UnregisterWait ( HANDLE  hWait)

See [MSDN] UnregisterWait().

Definition at line 200 of file SyncObj.cpp.

◆ operator HANDLE()

TSyncObj::operator HANDLE ( )
inline

Definition at line 97 of file SyncObj.h.

◆ GetHandle()

HANDLE TSyncObj::GetHandle ( )
inline

Definition at line 98 of file SyncObj.h.

◆ Initialized()

bool TSyncObj::Initialized ( )
inline

Definition at line 99 of file SyncObj.h.

◆ Duplicate()

HANDLE TSyncObj::Duplicate ( HANDLE  TargetProc,
bool  Inherit,
ACCESS_MASK  Access = 0,
DWORD  Opt = DUPLICATE_SAME_ACCESS 
)

See [MSDN] DuplicateHandle().
Note: The default Opt will request same access, ignoring Access.

Definition at line 205 of file SyncObj.cpp.

Member Data Documentation

◆ _hSync

HANDLE TSyncObj::_hSync
protected

Definition at line 79 of file SyncObj.h.


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