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

#include <uLib/SyncObj.h>

Inheritance diagram for TWaitTimer:
TSyncObj

Detailed Description

TWaitTimer encapsulates a Waitable Timer object.

Note: TWaitTimer does not release waiters like the other uLib sync objects
when it is destroyed, it just cancels the timer and closes it's handle.

This is because to release waiters, it would have to call SetWaitableTimer
with Due = Now, and whatever parameters was last used to set the timer,
which would necessitate memorizing all those parameters.

Ergo, never use INFINITE when waiting on this object.

Definition at line 178 of file SyncObj.h.

Public Functions

 TWaitTimer (LPSECURITY_ATTRIBUTES SecAttr, bool Manual, CSTR Name=NULL)
 
 TWaitTimer (DWORD Access, bool Inherit, CSTR Name)
 
 ~TWaitTimer ()
 
bool Set (FILETIME Due, LONG Period, PTIMERAPCROUTINE Action, PVOID Context, bool Resume)
 
bool Set (INT64 Due, LONG Period, PTIMERAPCROUTINE Action, PVOID Context, bool Resume)
 
bool Cancel ()
 
- Public Functions inherited from TSyncObj
 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)
 

Additional Inherited Members

- Protected Attributes inherited from TSyncObj
HANDLE _hSync
 

Constructor & Destructor Documentation

◆ TWaitTimer() [1/2]

TWaitTimer::TWaitTimer ( LPSECURITY_ATTRIBUTES  SecAttr,
bool  Manual,
CSTR  Name = NULL 
)

Create a waitable timer.
See CreateWaitableTimer().

Definition at line 325 of file SyncObj.cpp.

◆ TWaitTimer() [2/2]

TWaitTimer::TWaitTimer ( DWORD  Access,
bool  Inherit,
CSTR  Name 
)

Open an existing waitable timer.
See OpenWaitableTimer().

Definition at line 330 of file SyncObj.cpp.

◆ ~TWaitTimer()

TWaitTimer::~TWaitTimer ( )

Cancel this timer and close it's handle.

Definition at line 335 of file SyncObj.cpp.

Member Function Documentation

◆ Set() [1/2]

bool TWaitTimer::Set ( FILETIME  Due,
LONG  Period,
PTIMERAPCROUTINE  Action,
PVOID  Context,
bool  Resume 
)

Set an absolute Due time for this timer...
The completion routine will be executed by the same thread that called Set,
when that thread is waiting in an alertable state (f.ex. SleepEx() or this->Wait()).
See SetWaitableTimer(..).

Note: The Now() and AddTime() functions (in UtilFunc)
make it easy to set up an absolute Due time for waitable timers.

FILETIME Due = AddTime( Now( SYSTEM_TIME ), 1,0,0,0 ); // In an hour

Definition at line 340 of file SyncObj.cpp.

◆ Set() [2/2]

bool TWaitTimer::Set ( INT64  Due,
LONG  Period,
PTIMERAPCROUTINE  Action,
PVOID  Context,
bool  Resume 
)

Set a relative Due time for this timer.
Due should be a negative value, in 100 ns increments.
If it is positive, this function will negate it for you.
See SetWaitableTimer(..).

Definition at line 347 of file SyncObj.cpp.

◆ Cancel()

bool TWaitTimer::Cancel ( )

Cancel this timer.
See CancelWaitableTimer(..).

Definition at line 356 of file SyncObj.cpp.


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