CCallbackTimerQueueEx Class Reference
[Timer management]

Inheritance diagram for CCallbackTimerQueueEx:

Inheritance graph
[legend]
Collaboration diagram for CCallbackTimerQueueEx:

Collaboration graph
[legend]

List of all members.


Detailed Description

A class that manages a group of timers that implement IQueueTimers::Timer and which have their IQueueTimers::Timer::OnTimer() method called when the timer expires. You must manually manage the handling and processing of timeouts by calling either IManageTimerQueue::HandleTimeouts() or IManageTimerQueue::BeginTimeoutHandling() every IManageTimerQueue::GetNextTimeout() milliseconds. See here for more details. Note: the maximum timeout that you can set is 4294967294ms as 0xFFFFFFF is reserved as 'INFINITE' i.e. a timer that never expires. Internally the code uses an unsigned 64 bit counter which will wrap in around 584942417.4 years from the creation of the timer queue. You cannot set a timer that crosses this wrap point and an exception will be thrown. GetMaximumTimeout() does not report the reducing maximum timeout as the wrap point approaches, it will always return 4294967294ms.


Public Types

typedef ULONG_PTR * TimeoutHandle
 A handle to a timer that has been timed out. This can be passed to HandleTimeout() and EndTimeoutHandling() and is obtained by calling BeginTimeoutHandling().
typedef ULONG_PTR UserData
 User data that can be passed to Timer via the OnTimer() call when the timeout expires.
typedef ULONG_PTR Handle
 A handle to a timer that has been created. This can be passed to SetTimer(), CancelTimer() and DestroyTimer() and is created with CreateTimer().

Public Member Functions

 CCallbackTimerQueueEx ()
 Create a timer queue.
 CCallbackTimerQueueEx (const IProvideTickCount64 &tickProvider)
 Create a timer queue that uses the provdided instance of IProvideTickCount64 to obtain its tick counts rather than getting them directly from the system.
virtual ~CCallbackTimerQueueEx ()
virtual Milliseconds GetNextTimeout ()
 Get the number of milliseconds until the next timer is due to fire. Or INFINITE if no timer is set.
virtual void HandleTimeouts ()
 Process any timers that have timed out. Note that in an implementation that is safe for use in a multi-threaded situation it is acceptable to hold a lock whilst this method is called to prevent concurrent calls to any of the methods on IQueueTimers.
virtual
IManageTimerQueue::TimeoutHandle 
BeginTimeoutHandling ()
 Returns the handle of a timer than needs to be handled, or InvalidTimeoutHandleValue if no timers currenly need to be handled. Note that in an implementation that is safe for use in a multi-threaded situation it is acceptable to hold a lock whilst this method is called to prevent concurrent calls to any of the methods on IQueueTimers.
virtual void HandleTimeout (IManageTimerQueue::TimeoutHandle &handle)
 Handle the timeout for the given timer handle. Note that in an implementation that is safe for use in a multi-threaded situation it is NOT acceptable to hold a lock that will prevent concurrent calls to any of the methods on IQueueTimers.
virtual void EndTimeoutHandling (IManageTimerQueue::TimeoutHandle &handle)
 Complete the handling of a timeout that was started with BeginTimeoutHandling(). Note that in an implementation that is safe for use in a multi-threaded situation it is acceptable to hold a lock whilst this method is called to prevent concurrent calls to any of the methods on IQueueTimers.
virtual
IQueueTimers::Handle 
CreateTimer ()
 Create a timer and return a Handle to it.
virtual bool SetTimer (const IQueueTimers::Handle &handle, IQueueTimers::Timer &timer, const Milliseconds timeout, const IQueueTimers::UserData userData)
 Set a timer that was previously created with CreateTimer(). Returns true if the timer was previously pending for another timeout and false if the timer was not already pending. Note that calling SetTimer() will cause any timers that have expired to be processed before the new timer is set.
virtual void SetTimer (IQueueTimers::Timer &timer, const Milliseconds timeout, const IQueueTimers::UserData userData)
 Create and set a single use timer. Note that calling SetTimer() will cause any timers that have expired to be processed before the new timer is set.
virtual bool CancelTimer (const IQueueTimers::Handle &handle)
 Cancel a timer that was previously set with SetTimer(). Returns true if the timer was pending and false if the timer was not pending.
virtual bool DestroyTimer (IQueueTimers::Handle &handle)
 Destroy a timer that was previously created with CreateTimer() and update the variable passed in to contain InvalidHandleValue. Note that it is not permitted to call DestroyHandle() on a handle that contains the InvalidHandleValue value and an exception is thrown in this case. Returns true if the timer was pending and false if the timer was not pending.
virtual bool DestroyTimer (const IQueueTimers::Handle &handle)
 Destroy a timer that was previously created with CreateTimer(). Returns true if the timer was pending and false if the timer was not pending.
virtual Milliseconds GetMaximumTimeout () const
 Returns the maximum timeout value that can be set. Note that this may differ between instances of the objects that implement this interface.
virtual bool DispatchesWithoutLock () const
 Returns true if the queue dispatches timers without holding an internal lock which it also requires to manipulate timers.

Static Public Attributes

static TimeoutHandle InvalidTimeoutHandleValue = 0
 The value that represents an invalid handle that cannot be used.
static Handle InvalidHandleValue = 0
 The value that represents an invalid handle that cannot be used.

Protected Member Functions

bool SetInternalTimer (const IQueueTimers::Handle &handle, IQueueTimers::Timer &timer, const ULONGLONG absoluteTimeout)


Member Typedef Documentation

typedef ULONG_PTR* TimeoutHandle [inherited]

A handle to a timer that has been timed out. This can be passed to HandleTimeout() and EndTimeoutHandling() and is obtained by calling BeginTimeoutHandling().

typedef ULONG_PTR UserData [inherited]

User data that can be passed to Timer via the OnTimer() call when the timeout expires.

typedef ULONG_PTR Handle [inherited]

A handle to a timer that has been created. This can be passed to SetTimer(), CancelTimer() and DestroyTimer() and is created with CreateTimer().


Constructor & Destructor Documentation

CCallbackTimerQueueEx (  ) 

Create a timer queue.

CCallbackTimerQueueEx ( const IProvideTickCount64 tickProvider  )  [explicit]

Create a timer queue that uses the provdided instance of IProvideTickCount64 to obtain its tick counts rather than getting them directly from the system.

~CCallbackTimerQueueEx (  )  [virtual]


Member Function Documentation

Milliseconds GetNextTimeout (  )  [virtual, inherited]

Get the number of milliseconds until the next timer is due to fire. Or INFINITE if no timer is set.

Implements IManageTimerQueue.

void HandleTimeouts (  )  [virtual, inherited]

Process any timers that have timed out. Note that in an implementation that is safe for use in a multi-threaded situation it is acceptable to hold a lock whilst this method is called to prevent concurrent calls to any of the methods on IQueueTimers.

Implements IManageTimerQueue.

IManageTimerQueue::TimeoutHandle BeginTimeoutHandling (  )  [virtual, inherited]

Returns the handle of a timer than needs to be handled, or InvalidTimeoutHandleValue if no timers currenly need to be handled. Note that in an implementation that is safe for use in a multi-threaded situation it is acceptable to hold a lock whilst this method is called to prevent concurrent calls to any of the methods on IQueueTimers.

Implements IManageTimerQueue.

void HandleTimeout ( IManageTimerQueue::TimeoutHandle handle  )  [virtual, inherited]

Handle the timeout for the given timer handle. Note that in an implementation that is safe for use in a multi-threaded situation it is NOT acceptable to hold a lock that will prevent concurrent calls to any of the methods on IQueueTimers.

Implements IManageTimerQueue.

void EndTimeoutHandling ( IManageTimerQueue::TimeoutHandle handle  )  [virtual, inherited]

Complete the handling of a timeout that was started with BeginTimeoutHandling(). Note that in an implementation that is safe for use in a multi-threaded situation it is acceptable to hold a lock whilst this method is called to prevent concurrent calls to any of the methods on IQueueTimers.

Implements IManageTimerQueue.

CCallbackTimerQueueBase::Handle CreateTimer (  )  [virtual, inherited]

Create a timer and return a Handle to it.

Implements IQueueTimers.

virtual bool SetTimer ( const IQueueTimers::Handle handle,
IQueueTimers::Timer timer,
const Milliseconds  timeout,
const IQueueTimers::UserData  userData 
) [virtual, inherited]

Set a timer that was previously created with CreateTimer(). Returns true if the timer was previously pending for another timeout and false if the timer was not already pending. Note that calling SetTimer() will cause any timers that have expired to be processed before the new timer is set.

Implements IQueueTimers.

virtual void SetTimer ( IQueueTimers::Timer timer,
const Milliseconds  timeout,
const IQueueTimers::UserData  userData 
) [virtual, inherited]

Create and set a single use timer. Note that calling SetTimer() will cause any timers that have expired to be processed before the new timer is set.

Implements IQueueTimers.

virtual bool CancelTimer ( const IQueueTimers::Handle handle  )  [virtual, inherited]

Cancel a timer that was previously set with SetTimer(). Returns true if the timer was pending and false if the timer was not pending.

Implements IQueueTimers.

virtual bool DestroyTimer ( IQueueTimers::Handle handle  )  [virtual, inherited]

Destroy a timer that was previously created with CreateTimer() and update the variable passed in to contain InvalidHandleValue. Note that it is not permitted to call DestroyHandle() on a handle that contains the InvalidHandleValue value and an exception is thrown in this case. Returns true if the timer was pending and false if the timer was not pending.

Implements IQueueTimers.

virtual bool DestroyTimer ( const IQueueTimers::Handle handle  )  [virtual, inherited]

Destroy a timer that was previously created with CreateTimer(). Returns true if the timer was pending and false if the timer was not pending.

Implements IQueueTimers.

Milliseconds GetMaximumTimeout (  )  const [virtual, inherited]

Returns the maximum timeout value that can be set. Note that this may differ between instances of the objects that implement this interface.

Implements IQueueTimers.

bool DispatchesWithoutLock (  )  const [virtual, inherited]

Returns true if the queue dispatches timers without holding an internal lock which it also requires to manipulate timers.

Implements IQueueTimers.

bool SetInternalTimer ( const IQueueTimers::Handle handle,
IQueueTimers::Timer timer,
const ULONGLONG  absoluteTimeout 
) [protected, inherited]


Member Data Documentation

IManageTimerQueue::TimeoutHandle InvalidTimeoutHandleValue = 0 [static, inherited]

The value that represents an invalid handle that cannot be used.

IQueueTimers::Handle InvalidHandleValue = 0 [static, inherited]

The value that represents an invalid handle that cannot be used.


Generated on Thu Mar 26 16:40:27 2009 for JetByte Socket Tools - v6.0 by  doxygen 1.5.3