resmgr_context_alloc()

Updated: May 06, 2022

Allocate a resource-manager context

Synopsis:

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

resmgr_context_t* resmgr_context_alloc( dispatch_t * dpp );

Arguments:

dpp
A dispatch handle created by a successful call to dispatch_create().

Library:

libc

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

Description:

The resmgr_context_alloc() function returns a context that's used for blocking and receiving messages.

Note: This function simply calls dispatch_context_alloc().

Returns:

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

Errors:

EINVAL
No resource manager events were attached to dpp.
ENOMEM
Insufficient memory to allocate the context ctp.

Examples:

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

int main( int argc, char **argv ) {
   dispatch_t          *dpp;
   resmgr_context_t    *ctp;

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

   …

   if ( ( ctp = resmgr_context_alloc ( dpp )) == NULL ) {
      fprintf( stderr, "Context wasn't allocated.\n" );
      return EXIT_FAILURE;
   }
}

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

Classification:

QNX Neutrino

Safety:  
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes