Handle events received by dispatch_block()


#include <sys/iofunc.h>
#include <sys/dispatch.h>

int dispatch_handler( dispatch_context_t * ctp );


A pointer to a dispatch_context_t structure that was allocated by dispatch_context_alloc().



Use the -l c option to qcc to link against this library. This library is usually included automatically.


The dispatch_handler() function handles events received by dispatch_block(). This function is part of the dispatch layer of a resource manager. For more information, see "Layers in a resource manager" in the Bones of a Resource Manager chapter of Writing a Resource Manager.

Depending on the blocking type, dispatch_handler() does one of the following:


One of the following occurred:
  • The message was a _PULSE_CODE_THREADDEATH pulse message (see ChannelCreate()) for which there's no default handler function.
  • The message length was less than 2 bytes. A 2-byte message type is required at the beginning of the message so that a handler function can be found or identified.
  • The message wasn't in native endian format and there were no handler functions that specified MSG_FLAG_CROSS_ENDIAN on this range, even though a handler was registered for it using message_attach(). The MSG_FLAG_CROSS_ENDIAN flag wasn't given to message_attach().
  • A handler was found for the message, but the handler determined that there was a problem.

In any case, if the message wasn't a pulse, then the client will be replied to with an appropriate errno.


#include <stdlib.h>
#include <sys/dispatch.h>

int main( int argc, char **argv ) {
   dispatch_context_t   *ctp;


   for(;;) {
     if( ctp = dispatch_block( ctp ) ) {
       dispatch_handler( ctp );
   return EXIT_SUCCESS;

For examples using the dispatch interface, see dispatch_create(), message_attach(), resmgr_attach(), and thread_pool_create().


QNX Neutrino

Cancellation point Read the Caveats
Interrupt handler No
Signal handler No
Thread Yes


This function might or might not be a cancellation point, depending on the implementation of the handler.