- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Static Public Member Functions

# MTimerMessage Class Reference
OpenMaya - API module for common classes

Search for all occurrences

## Detailed Description

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.

`#include <MTimerMessage.h>`

Inheritance diagram for MTimerMessage:
[legend]

List of all members.

## Public Types
typedef void(* | sleepCallbackPtr )()
| Pointer to a sleep callback function.
## 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.
static const char * | className ()
| Returns the name of this class.
static MStatus | setSleepCallback (sleepCallbackPtr sleepFunc)
| This method is obsolete.
static MTimerMessage::sleepCallbackPtr | sleepCallback ()
| This method is obsolete. Search for all occurrences

## Member Function Documentation

MCallbackId addTimerCallback | ( | float | period,
|  | MMessage::MElapsedTimeFunction | func,
|  | void * | clientData = `NULL`,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | `[static]`

Search for all occurrences

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.

The callback function will be passed any client data that was provided when the callback was registered.

Parameters:

  [in] | period | the period at which the callback will be executed (Measured in seconds)
  [in] | func | the callback function elapsedTime The elapsed time since this function was last called lastTime The execution time of this function the the last time it was called clientData User defined data passed to the callback function
  [in] | clientData | User defined data that will be passed to the callback function
  [out] | ReturnStatus | status code

Returns:
  Identifier used for removing the callback.

Status Codes:
  - MS::kSuccess Operation succeeded
  - MS::kInsufficientMemory No memory available
  - MS::kFailure Error adding callback

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

Reimplemented from MMessage.

MStatus setSleepCallback | ( | sleepCallbackPtr | sleepFunc | ) | `[static]`

Search for all occurrences

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.

Parameters:

  [in] | sleepFunc | a function pointer to a function that will cause the current process to sleep

Returns:
  - MS::kSuccess Operation succeeded
  - MS::kFailure Undefined Error

MTimerMessage::sleepCallbackPtr sleepCallback | ( |  | ) | `[static]`

Search for all occurrences

This method is obsolete.

Returns the currently registered sleep callback function.

MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage
MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage MTimerMessage