Register a function for eventual execution.
BPS_API int bps_channel_exec(int chid, int(*exec)(void *), void *data)
The channel ID designating which channel event queue to enqueue the exec callback.
The function that will be executed. The first argument to the callback will be the data that is passed to bps_channel_exec() function. Any returned result will be ignored.
The user data that will be used as the first argument of the invoke function.
Calling bps_channel_exec() registers the provided function by pushing an exec event onto the destination channel's (chid) event queue. The exec function will be executed during a call to bps_get_event() once the exec event is popped from the event queue. Note that the caller of bps_get_event() will not receive this exec event, it is entirely consumed by BPS and converted into a call to the exec function.
The bps_channel_exec() function works across threads. The channel chid can be owned by the same thread that is calling bps_channel_exec() or by an entirely different thread. When performing a cross-thread exec, care must be taken to safe-guard any data that is shared between the calling thread and the thread that owns the destination channel chid. The same precautions should be taken with the use of the data argument.
BPS_SUCCESS if the invoke callback was successfully registered with channel chid. BPS_FAILURE if registration failed. errno will be set to the cause of failure.