CommTimer Class Reference

#include <cs_port.h>

Link against: c32.lib

class CommTimer
Public Member Functions
CDeltaTimer *GetTimer()
IMPORT_C voidQueue(TTimeIntervalMicroSeconds32, TDeltaTimerEntry &)
IMPORT_C voidRemove(TDeltaTimerEntry &)

Detailed Description

Static utility class for global timer handling designed for use by Serial Server plug-ins (CSYs).

Member Function Documentation

GetTimer ( )

CDeltaTimer *GetTimer()[static]

Get the pointer to the global timer. If it does not exist, create a new timer and store the pointer in the TLS.

Only clients within CSYs should use this API, since this function has a legacy behaviour of panicking in the case of no memory. This is due to the API not containing a means to communicate this result back to the caller. In the case where GetTimer is used by a CSY this is not a problem since the CSY will be running in a thread that C32 has already allocated the CommTimer memory for.

Note:

This function is using TLS (Thread Local Storage) and may reduce performance.

Returns: pointer to the timer

Queue ( TTimeIntervalMicroSeconds32, TDeltaTimerEntry & )

IMPORT_C voidQueue(TTimeIntervalMicroSeconds32aTimeInMicroSeconds,
TDeltaTimerEntry &aHandle
)[static]

Queue a timer on the global timer.

This class is only suitable for CSYs since it currently has no direct mechanism through which to release the Thread Local Storage and heap resources it allocates. In the case of CSYs these resources are managed separately by C32.

Note:

1. The Thread Local Storage of the calling thread must be available for use.

2. The first time this is called for a thread, a small amount of heap memory is required. If no memory is available, a "c32-fault" panic of type 7 is raised. Subsequent calls are not affected since they reuse this memory.

ParameterDescription
aTimeInMicroSecondsthe timeout value in micro seconds
aHandlehandle to the delta timer entry

Remove ( TDeltaTimerEntry & )

IMPORT_C voidRemove(TDeltaTimerEntry &aHandle)[static]

Call cancel on the global timer

Note: This does not free the Thread Local Storage for the calling thread.

ParameterDescription
aHandlethe timer to cancel