![]() |
![]() |
![]() |
![]() |
![]() |
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Set a timeout
#include <sys/iofunc.h>
#include <sys/dispatch.h>
int dispatch_timeout( dispatch_t *dpp,
struct timespec *reltime );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The function dispatch_timeout() sets a timeout that's used when blocking with dispatch_block().
This function is part of the dispatch layer of a resource manager. For more information, see "Components of a resource manager" in the Writing a Resource Manager chapter of the Neutrino Programmer's Guide.
#include <sys/dispatch.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char **argv ) {
dispatch_t *dpp;
struct timespec time_out;
int timedout;
time_out.tv_sec = 1;
time_out.tv_nsec = 2;
if( ( dpp = dispatch_create() ) == NULL ) {
fprintf( stderr, "%s: Unable to allocate \
dispatch handle.\n",argv[0] );
return EXIT_FAILURE;
}
...
if ( (timedout = dispatch_timeout ( dpp, &time_out ))
== -1 ) {
fprintf ( stderr, "Couldn't set timeout );
return EXIT_FAILURE;
}
/* else successful timeout set */
...
return EXIT_SUCCESS;
}
For examples using the dispatch interface, see dispatch_create(), message_attach(), resmgr_attach(), and thread_pool_create().
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |
dispatch_block(), dispatch_create(), dispatch_handler(), dispatch_unblock() timespec
"Components of a resource manager" in the Writing a Resource Manager chapter of the Neutrino Programmer's Guide
![]() |
![]() |
![]() |
![]() |