pulse_detach()

Updated: October 28, 2024

Detach a handler function from a pulse code

Synopsis:

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

int pulse_detach( dispatch_t * dpp,
                  int code,
                  int flags );

Arguments:

dpp
The dispatch handle, as returned by a successful call to dispatch_create().
code
The pulse code that you want to detach.
flags
Reserved; pass 0 for this argument.

Library:

libc

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

Description:

The pulse_detach() function detaches the pulse code, for dispatch handle dpp, that was attached with pulse_attach().

Returns:

0
Success.
-1
The pulse code doesn't match any attached pulse code or you called pulse_detach() for an active dpp with DISPATCH_FLAG_NOLOCK set.

Examples:

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

int my_func( … ) {

   …

}
    
int main( int argc, char **argv ) {
   dispatch_t    *dpp;
   int           flag=0, code, mycode;
    
   if ( ( dpp = dispatch_create() ) == NULL ) {
      fprintf( stderr, "%s: Unable to allocate \
               dispatch handle.\n",argv[0] );
      return EXIT_FAILURE;
   }

   …
   if ( (code = pulse_attach( dpp, flag, mycode,
                &my_func, NULL)) == -1 ) {
       fprintf ( stderr, "Failed to attach pulse code %d.\n", \
                 mycode );
       return 1;
   }
    
   …

   if ( pulse_detach ( dpp, code, flag ) == -1 ) {
      fprintf ( stderr, "Failed to detach code %d.\n", code );
      return 1;
   }
   /* else message was detached */
            
   …
}

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
  翻译: