|
uLib
User mode C/C++ extended API library for Win32 programmers.
|
#include <uLib/SyncObj.h>
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.
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 |
| TSyncObj::TSyncObj | ( | ) |
Definition at line 123 of file SyncObj.cpp.
| TSyncObj::TSyncObj | ( | const HANDLE & | Src | ) |
Definition at line 127 of file SyncObj.cpp.
| TSyncObj::~TSyncObj | ( | ) |
Definition at line 131 of file SyncObj.cpp.
| bool TSyncObj::Close | ( | ) |
Definition at line 136 of file SyncObj.cpp.
| bool TSyncObj::Wait | ( | DWORD | msWait | ) |
See [MSDN] WaitForSingleObject().
Definition at line 153 of file SyncObj.cpp.
| bool TSyncObj::WaitEx | ( | DWORD | msWait, |
| bool | Alertable | ||
| ) |
See [MSDN] WaitForSingleObjectEx().
Definition at line 165 of file SyncObj.cpp.
| bool TSyncObj::SignalAndWait | ( | HANDLE | hWaitFor, |
| DWORD | msWait, | ||
| bool | Alertable | ||
| ) |
See [MSDN] SignalObjectAndWait().
Definition at line 177 of file SyncObj.cpp.
| 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.
| bool TSyncObj::UnregisterWait | ( | HANDLE | hWait | ) |
See [MSDN] UnregisterWait().
Definition at line 200 of file SyncObj.cpp.
| 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.