class MTimerMessage

Jump to documentation

: public MMessage Register callbacks that are based on a fixed time interval. (OpenMaya) (OpenMaya.py)

Inheritance:

MTimerMessage < MMessage

public members:

static MCallbackId addTimerCallback ( float period, MMessage::MElapsedTimeFunction func, void * clientData = NULL, MStatus * ReturnStatus = NULL )
static MStatus setSleepCallback ( sleepCallbackPtr sleepFunc )
static MTimerMessage::sleepCallbackPtr sleepCallback ( )

Inherited from MMessage:

public members:

static MStatus removeCallback ( MCallbackId id )
static MStatus removeCallbacks ( MCallbackIdArray &ids )
static MCallbackId currentCallbackId ( MStatus * ReturnStatus = NULL )
static MStatus nodeCallbacks ( MObject & node, MCallbackIdArray & ids )
static void setRegisteringCallableScript ()
static bool registeringCallableScript ()
static MStatus removeCallbacks ( MIntArray &ids )
static MStatus nodeCallbacks ( MObject & node, MIntArray & ids )

Documentation

Register callbacks that are based on a fixed time interval. (OpenMaya) (OpenMaya.py)
Description

This class is used to register callbacks that are called at fixed time intervals.

The add callback method returns an id which is used to remove the callback.

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.

Functions

MCallbackId MTimerMessage:: addTimerCallback ( float period, MMessage::MElapsedTimeFunction func, void * clientData, MStatus * ReturnStatus )
Description

This method registers a callback for timed messages. 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.

If the execution time of a callback exceeds its period/2 the timer will be reset. This will give Maya 1 period in which to do other things.

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

Arguments

  • period the period at which the callback will be executed (Measured in seconds)
  • 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

  • clientData User defined data that will be passed to the callback function
  • ReturnStatus status code

Return Value

  • identifier used for removing the callback.

Status Codes

  • MS::kSuccess Operation succeeded
  • MS::kInsufficientMemory No memory available
  • MS::kFailure Error adding callback

MStatus MTimerMessage:: setSleepCallback ( sleepCallbackPtr sleepFunc )
Description

The sleep function is a mechanism that allows the user to limit the ammount of CPU time that Maya uses while a timer callback is registered. Normally, registering a timer callback will cause Maya's event loop to run continuously and consume 100% of the available processor time. In some cases it may be desireable to use a sleep callback that will put Maya's event loop to sleep for a few miliseconds if there are no pending events. This will give another process time to do some other task.

The sleep function is optional.

Maya will not execute any faster when using a sleep function.

The sleep function is global and used when any timer message callbacks are registered.

Nanosleep() is a good candidate to achieve the desired results, however other platform dependent methods may be used to achieve finer sleep resolution if available.

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.

Always use this method to set the sleep function to NULL when unloading your plugin. You can also use sleepCallback() to check if your sleep function is currently active to avoid conflicts with another plugin that has overridden your sleep function

Arguments

  • sleepFunc a function pointer to a function that will cause the current process to sleep

Return Value

  • MStatus

Status Codes

  • MS::kSuccess Operation succeeded
  • MS::kFailure Undefined Error

MTimerMessage::sleepCallbackPtr MTimerMessage:: sleepCallback ( )
Description

Returns the currently registered sleep callback function

This class has no child classes.


Autodesk® Maya® 8.0 © 1997-2006 Autodesk, Inc. All rights reserved. doc++ Copyright