FireSync API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kStatus kSystem_SetHealthHandler ( kSystem  system,
kCallbackFx  function,
kPointer  receiver 
)

Registers a callback function that can be used to receive health messages.

If a health callback will be used, it should be registered prior to opening any sensor health connections. The callback cannot be changed while sensors are sending health messages.

The callback function will be asynchronously invoked in a background thread. It can be called at any time, until the callback is unregistered. Various internal locks may be held by the thread that invokes the callback; accordingly, the implementation of the callback should avoid acquiring any locks that might result in deadlock. In particular, this includes any locks that might be held by the application when opening or closing health connections. If in doubt, the safest course is to enqueue the received health messages for processing by another application thread, or use the kSystem_ReceiveHealth method instead of kSystem_SetHealthHandler.

Message objects (kHealthMsg) received by the registered callback function should be disposed (kObject_Dispose) when no longer needed. Health messages can be retained beyond the duration of the callback.

Callbacks can be used as an alternative to kSystem_ReceiveHealth, but cannot be used at the same time (registering a callback will prevent kSystem_ReceiveHealth from working).

Parameters
systemSystem object.
functionHealth handler function, or kNULL to unregister the callback.
receiverUser-defined context pointer, to be passed to the callback function.
Returns
Operation status.