Handle resource manager messages
#include <sys/iofunc.h> #include <sys/dispatch.h> int resmgr_handler( resmgr_context_t * ctp );
BlackBerry 10.0.0
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The resmgr_handler() function handles the message received in ctp. This function handles different I/O messages through the resource manager framework.
#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;
}
…
ctp = resmgr_context_alloc( dpp );
while (1) {
if ( ( ctp = resmgr_block( ctp )) == NULL ) {
fprintf( stderr, "block error\n" );
return EXIT_FAILURE;
}
resmgr_handler( ctp );
}
}
For examples using the dispatch interface, see dispatch_create() , message_attach() , resmgr_attach() , and thread_pool_create() .
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |
If you attach messages or pulses to dpp by calling message_attach() , pulse_attach() , or select_attach() , those events aren't dispatched by resmgr_handler(). Instead, you should call dispatch_handler() .