#include <MTimerMessage.h>
Register callbacks that are based on a fixed time interval.
This class is used to register callbacks that are called at fixed time intervals.
To remove a callback use MMessage::removeCallback.
All callbacks that are registered by a plug-in must be removed by that plug-in when it is unloaded. Failure to do so will result in a fatal error.
Public Types | |
typedef void(* | sleepCallbackPtr) () |
Pointer to a sleep callback function. | |
Callback result action codes. More... |
Static Public Member Functions | |
static MCallbackId | addTimerCallback (float period, MMessage::MElapsedTimeFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
This method registers a callback which is called repeatedly with a specified period of time between calls. More... | |
static const char * | className () |
Returns the name of this class. More... | |
static MStatus | setSleepCallback (sleepCallbackPtr sleepFunc) |
This method is obsolete. More... | |
static MTimerMessage::sleepCallbackPtr | sleepCallback () |
This method is obsolete. More... | |
|
static |
This method registers a callback which is called repeatedly with a specified period of time between calls.
Each time the timer fires the callback will be placed on the idle queue for execution in the next idle cycle. If the timer fires again, before the previous invocation has completed execution, the new firing will be skipped.
If the execution time of the callback exceeds half of its period then the next timeout will be skipped to give Maya time to process other tasks.
The maximum resolution for this callback is about 1ms. The response is, however, not guaranteed because while multitasking, the OS may delay for an unspecified length of time before returning control to Maya.
[in] | period | the period at which the callback will be executed (Measured in seconds) |
[in] | func | the callback function
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Returns the name of this class.
|
static |
This method is obsolete.
The sleep callback is executed on each idle cycle in which there are are no other idle tasks currently awaiting execution, but one or more timer callbacks have been registered.
The original implementation of addTimerCallback() was such that Maya's idle queue would run continuously so long as there were timer callbacks registered. The purpose of the sleep callback was to put the idle queue to sleep for a while so as to give non-Maya processes a chance to execute.
addTimerCallback() has since been changed so that the idle queue does not run continously, so the sleep callback is no longer necessary. It is only provided now for backwards compatibility.
There is only one sleep callback. Setting the callback with this method will replace any existing sleep callback. The sleepCallback() method can be used to check for an existing callback.
Using this method will limit the response time of all timer callbacks to slightly more than the length of the sleep function. So if your sleep function sleeps for 20ms, any timer that is smaller than 20ms will be called at 20ms intervals.
If you use this method to set a sleep callback, remember to reset it when the callback is no longer needed, for example, when your plugin is unloaded.
[in] | sleepFunc | a function pointer to a function that will cause the current process to sleep |
|
static |
This method is obsolete.
Returns the currently registered sleep callback function.