dispatch_handler()

Handle events received by dispatch_block()

Synopsis:

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

int dispatch_handler( dispatch_context_t * ctp );

Arguments:

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

Library:

libc

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

Description:

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:

Returns:

0
Success.
-1
One of the following occurred:

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

Examples:

#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().

Classification:

QNX Neutrino

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

Caveats:

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

See also:

dispatch_block(), dispatch_create(), dispatch_create_channel(), dispatch_timeout()

Layers in a resource manager in the Bones of a Resource Manager chapter of Writing a Resource Manager