Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/d/dispatch_context_alloc.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/d/dispatch_context_alloc.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/d/dispatch_context_alloc.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/d/dispatch_context_alloc.html on line 8

dispatch_context_alloc()

Return a dispatch context

Synopsis:

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

dispatch_context_t * dispatch_context_alloc
                   ( dispatch_t * dpp );

Arguments:

dpp
A dispatch handle created by dispatch_create().

Library:

libc

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

Description:

The dispatch_context_alloc() function returns a dispatch context pointer. The function is passed in the handle dpp from dispatch_create(). The dispatch context is used by dispatch to do its work. It's passed as an argument to dispatch_block() and dispatch_handler().


Note: The dispatch_context_alloc() function fails if you haven't attached any events to dispatch yet (e.g. you didn't call message_attach(), resmgr_attach(), or select_attach()). The dispatch library can't allocate a proper context until it knows what kind of events you want to 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.

Returns:

A pointer to a dispatch context, or NULL if an error occurs (errno is set).

Errors:

EINVAL
No events were attached.
ENOMEM
Insufficient memory to allocate context.

Examples:

#include <sys/dispatch.h>
#include <stdio.h>    
#include <stdlib.h>   
    
int main( int argc, char **argv ) {
   dispatch_t           *dpp;
   dispatch_context_t   *ctp;

   if( ( dpp = dispatch_create() ) == NULL ) {
     fprintf( stderr, "%s: Unable to allocate \
              dispatch handle.\n",argv[0] );
     return EXIT_FAILURE;
   }

   &vellip;

   ctp = dispatch_context_alloc( dpp );

   &vellip;

   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 No
Interrupt handler No
Signal handler No
Thread Yes

See also:

dispatch_block(), dispatch_context_free(), dispatch_create(), dispatch_create_channel(), dispatch_handler(), dispatch_unblock()

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


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/d/dispatch_context_alloc.html on line 193

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/d/dispatch_context_alloc.html on line 193