The C++ framework for developing highly scalable, high performance servers on Windows platforms.

CThreadedCallbackTimerQueue Class Reference

Inheritance diagram for CThreadedCallbackTimerQueue:
Collaboration diagram for CThreadedCallbackTimerQueue:

List of all members.

Public Types

enum  SetTimerIf { SetTimerAlways, SetTimerIfNotSet }
 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. More...
enum  UpdateTimerIf { UpdateTimerIfNewTimeIsSooner, UpdateTimerIfNewTimeIsLater, UpdateAlways, UpdateAlwaysNoTimeoutChange }
 Update a timer if it is set and if the condition is true and set the timer if it is not set. Updating a timer will set the timeout, timer and user data to the newly supplied values. If the timer is not updated because the condition is false then nothing is changed. UpdateAlways will always update. UpdateAlwaysNoTimeoutChange will always update JUST timer and user data. If you supply pWasUpdated then it is set to true if anything was changed and false if not. More...
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

 CThreadedCallbackTimerQueue ()
 Create a timer queue.
 CThreadedCallbackTimerQueue (const JetByteTools::Core::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.
 CThreadedCallbackTimerQueue (JetByteTools::Core::IManageTimerQueue &impl)
 Create a timer queue that uses the supplied instance of IManageTimerQueue as its implementation. Note that we don't take ownership of the implementation, it's up to you to manage its lifetime.
 CThreadedCallbackTimerQueue (const CThreadedCallbackTimerQueue &rhs)
CThreadedCallbackTimerQueueoperator= (const CThreadedCallbackTimerQueue &rhs)
void SetThreadName (const _tstring &threadName) const
 Sets the name of the timer queue thread as displayed in the Visual Studio debugger to the supplied name. By default the constructors set the name of the thread to "TimerQueue".
void BeginShutdown ()
 Starts the shutdown process and returns immediately.
bool WaitForShutdownToComplete (Milliseconds timeout=INFINITE)
 Initiates a shutdown (if one isn't already in progresss) and then waits for it to complete. Does not return until the shutdown has completed or the timeout has expired. Returns true if the shutdown is complete.
void DumpStats (const JetByteTools::Core::_tstring &message) const
Handle CreateTimer () override
 Create a timer and return a Handle to it.
bool TimerIsSet (const Handle &handle) const override
virtual bool TimerIsSet (const Handle &handle) const =0
 Returns true if the timer is currently set.
bool SetTimer (const Handle &handle, Timer &timer, Milliseconds timeout, UserData userData, SetTimerIf setTimerIf=SetTimerAlways, bool *pOptionalFirstToExpireHasChanged=nullptr) override
void SetTimer (Timer &timer, Milliseconds timeout, UserData userData, bool *pOptionalFirstToExpireHasChanged=nullptr) override
virtual bool SetTimer (const Handle &handle, Timer &timer, Milliseconds timeout, UserData userData, SetTimerIf setTimerIf=SetTimerAlways, bool *pOptionalFirstToExpireHasChanged=nullptr)=0
virtual void SetTimer (Timer &timer, Milliseconds timeout, UserData userData, bool *pOptionalFirstToExpireHasChanged=nullptr)=0
 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.
bool UpdateTimer (const Handle &handle, Timer &timer, Milliseconds timeout, UserData userData, UpdateTimerIf updateIf, bool *pWasUpdated=nullptr, bool *pOptionalFirstToExpireHasChanged=nullptr) override
virtual bool UpdateTimer (const Handle &handle, Timer &timer, Milliseconds timeout, UserData userData, UpdateTimerIf updateIf, bool *pWasUpdated=nullptr, bool *pOptionalFirstToExpireHasChanged=nullptr)=0
bool CancelTimer (const Handle &handle, bool *pOptionalFirstToExpireHasChanged=nullptr) override
virtual bool CancelTimer (const Handle &handle, bool *pOptionalFirstToExpireHasChanged=nullptr)=0
 Cancel a timer that was previously set with SetTimer(). Returns true if the timer was pending and false if the timer was not pending.
bool DestroyTimer (Handle &handle, bool *pOptionalFirstToExpireHasChanged=nullptr) override
virtual bool DestroyTimer (Handle &handle, bool *pOptionalFirstToExpireHasChanged=nullptr)=0
 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 Handle &handle, bool *pOptionalFirstToExpireHasChanged=nullptr)
 Destroy a timer that was previously created with CreateTimer(). Returns true if the timer was pending and false if the timer was not pending.
Milliseconds GetMaximumTimeout () const override
 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 OnThreadInitialised ()
 Called on the timer thread when the timer thread is started.
virtual void OnThreadShutdown ()
 Called on the timer thread when the thread is shutting down.
template<typename T>
bool SetTimerWithRefCountedUserData (const Handle &handle, Timer &timer, Milliseconds timeout, T *pUserData, SetTimerIf setTimerIf=SetTimerAlways, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T>
bool SetTimerWithRefCountedTimer (const Handle &handle, T &timer, Milliseconds timeout, UserData userData, SetTimerIf setTimerIf=SetTimerAlways, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T>
bool UpdateTimerWithRefCountedUserData (const Handle &handle, Timer &timer, Milliseconds timeout, T *pUserData, UpdateTimerIf updateIf, bool *pWasUpdated=nullptr, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T>
bool UpdateTimerWithRefCountedTimer (const Handle &handle, T &timer, Milliseconds timeout, UserData userData, UpdateTimerIf updateIf, bool *pWasUpdated=nullptr, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T>
bool CancelTimerWithRefCountedUserData (const Handle &handle, T &userData, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T>
bool CancelTimerWithRefCountedUserData (const Handle &handle, T *pUserData, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T>
bool CancelTimerWithRefCountedTimer (const Handle &handle, T &timer, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T, typename H>
bool DestroyTimerWithRefCountedUserData (H &handle, T &userData, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T, typename H>
bool DestroyTimerWithRefCountedUserData (H &handle, T *pUserData, bool *pOptionalFirstToExpireHasChanged=nullptr)
template<typename T, typename H>
bool DestroyTimerWithRefCountedTimer (H &handle, T &timer, bool *pOptionalFirstToExpireHasChanged=nullptr)

Static Public Attributes

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


Member Typedef Documentation

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().


Member Enumeration Documentation

enum SetTimerIf [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.

Enumerator:
SetTimerAlways 
SetTimerIfNotSet 

enum UpdateTimerIf [inherited]

Update a timer if it is set and if the condition is true and set the timer if it is not set. Updating a timer will set the timeout, timer and user data to the newly supplied values. If the timer is not updated because the condition is false then nothing is changed. UpdateAlways will always update. UpdateAlwaysNoTimeoutChange will always update JUST timer and user data. If you supply pWasUpdated then it is set to true if anything was changed and false if not.

Enumerator:
UpdateTimerIfNewTimeIsSooner 
UpdateTimerIfNewTimeIsLater 
UpdateAlways 
UpdateAlwaysNoTimeoutChange 


Constructor & Destructor Documentation

Create a timer queue.

Reimplemented from CThreadedCallbackTimerQueue.

CThreadedCallbackTimerQueue ( const JetByteTools::Core::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.

Reimplemented from CThreadedCallbackTimerQueue.

Create a timer queue that uses the supplied instance of IManageTimerQueue as its implementation. Note that we don't take ownership of the implementation, it's up to you to manage its lifetime.

Reimplemented from CThreadedCallbackTimerQueue.


Member Function Documentation

CThreadedCallbackTimerQueue& operator= ( const CThreadedCallbackTimerQueue rhs  ) 

void SetThreadName ( const _tstring threadName  )  const [inherited]

Sets the name of the timer queue thread as displayed in the Visual Studio debugger to the supplied name. By default the constructors set the name of the thread to "TimerQueue".

void BeginShutdown (  )  [inherited]

Starts the shutdown process and returns immediately.

bool WaitForShutdownToComplete ( Milliseconds  timeout = INFINITE  )  [inherited]

Initiates a shutdown (if one isn't already in progresss) and then waits for it to complete. Does not return until the shutdown has completed or the timeout has expired. Returns true if the shutdown is complete.

void DumpStats ( const JetByteTools::Core::_tstring message  )  const [inherited]

CThreadedCallbackTimerQueue::Handle CreateTimer (  )  [override, virtual, inherited]

Create a timer and return a Handle to it.

Implements IQueueTimers.

bool TimerIsSet ( const Handle handle  )  const [override, inherited]

virtual bool TimerIsSet ( const Handle handle  )  const [pure virtual, inherited]

Returns true if the timer is currently set.

bool SetTimer ( const Handle handle,
Timer &  timer,
Milliseconds  timeout,
UserData  userData,
SetTimerIf  setTimerIf = SetTimerAlways,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [override, inherited]

void SetTimer ( Timer &  timer,
Milliseconds  timeout,
UserData  userData,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [override, inherited]

virtual bool SetTimer ( const Handle handle,
Timer timer,
Milliseconds  timeout,
UserData  userData,
SetTimerIf  setTimerIf = SetTimerAlways,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [pure virtual, inherited]

virtual void SetTimer ( Timer timer,
Milliseconds  timeout,
UserData  userData,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [pure 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.

bool UpdateTimer ( const Handle handle,
Timer &  timer,
Milliseconds  timeout,
UserData  userData,
UpdateTimerIf  updateIf,
bool pWasUpdated = nullptr,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [override, inherited]

virtual bool UpdateTimer ( const Handle handle,
Timer timer,
Milliseconds  timeout,
UserData  userData,
UpdateTimerIf  updateIf,
bool pWasUpdated = nullptr,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [pure virtual, inherited]

bool CancelTimer ( const Handle handle,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [override, inherited]

virtual bool CancelTimer ( const Handle handle,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [pure 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.

bool DestroyTimer ( Handle handle,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [override, inherited]

virtual bool DestroyTimer ( Handle handle,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [pure 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.

virtual bool DestroyTimer ( const Handle handle,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, 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.

Milliseconds GetMaximumTimeout (  )  const [override, 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 OnThreadInitialised (  )  [virtual, inherited]

Called on the timer thread when the timer thread is started.

void OnThreadShutdown (  )  [virtual, inherited]

Called on the timer thread when the thread is shutting down.

bool SetTimerWithRefCountedUserData ( const Handle handle,
Timer timer,
Milliseconds  timeout,
T *  pUserData,
SetTimerIf  setTimerIf = SetTimerAlways,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool SetTimerWithRefCountedTimer ( const Handle handle,
T &  timer,
Milliseconds  timeout,
UserData  userData,
SetTimerIf  setTimerIf = SetTimerAlways,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool UpdateTimerWithRefCountedUserData ( const Handle handle,
Timer timer,
Milliseconds  timeout,
T *  pUserData,
UpdateTimerIf  updateIf,
bool pWasUpdated = nullptr,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool UpdateTimerWithRefCountedTimer ( const Handle handle,
T &  timer,
Milliseconds  timeout,
UserData  userData,
UpdateTimerIf  updateIf,
bool pWasUpdated = nullptr,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool CancelTimerWithRefCountedUserData ( const Handle handle,
T &  userData,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool CancelTimerWithRefCountedUserData ( const Handle handle,
T *  pUserData,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool CancelTimerWithRefCountedTimer ( const Handle handle,
T &  timer,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool DestroyTimerWithRefCountedUserData ( H &  handle,
T &  userData,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool DestroyTimerWithRefCountedUserData ( H &  handle,
T *  pUserData,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]

bool DestroyTimerWithRefCountedTimer ( H &  handle,
T &  timer,
bool pOptionalFirstToExpireHasChanged = nullptr 
) [inline, inherited]


Member Data Documentation

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

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


Generated on Sun Sep 12 19:07:04 2021 for The Server Framework - v7.4 by doxygen 1.5.3