FireSync API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kStatus kPxBlock_OnEngage ( kPxBlock  block)
protected

Virtual method that can be overridden to perform custom actions when a block is engaged.

Blocks are engaged shortly after being started. Once engaged, blocks are permitted to emit arbitrary asynchronous output messages (assuming that asynchronous messaging has been enabled on the block's output ports).

Blocks that only emit synchronous output messages, or that only emit asynchronous messages in response to received input messages, will not typically need to override OnEngage. However, if a block can emit spontaneous asynchronous messages (e.g., messages generated by a periodic timer thread, irrespective of any received messages), doing so before OnEngage will result in undefined behavior. As such, OnEngage may provide a convenient location to start asynchronous threads owned by the block. (Side note: blocks that create threads must respect the pipe's thread priority/affinity configuration, which can be determined by calling kPxBlock_ThreadPriorityClass, kPxBlock_ThreadPriorityOffset, and kPxBlock_ThreadAffinity).

The implementation of OnEngage is required to be thread-safe. Specifically, OnEngage may be invoked by the pipe framework simultaneous to the invocation of OnReceive. As such, the implementation of the OnEngage method should usually be limited to calling other thread-safe methods.

Parameters
blockBlock object.
Returns
Operation status.
See also
kPxBlock_Send, kPxPort_EnableAsynchronousData