MediaProcessors
Typedefs | Functions
interr_usleep.h File Reference

Interruptible usleep module. This module ("interruptible usleep") implements a wrapper to the 'usleep()' function to provide the possibility to interrupt the sleep state by 'unlocking' the module instance handler. More...

#include <sys/types.h>
#include <inttypes.h>
Include dependency graph for interr_usleep.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct interr_usleep_ctx_s interr_usleep_ctx_t
 

Functions

interr_usleep_ctx_tinterr_usleep_open ()
 
void interr_usleep_close (interr_usleep_ctx_t **ref_interr_usleep_ctx)
 
void interr_usleep_unblock (interr_usleep_ctx_t *interr_usleep_ctx)
 
int interr_usleep (interr_usleep_ctx_t *interr_usleep_ctx, uint32_t usec)
 

Detailed Description

Interruptible usleep module. This module ("interruptible usleep") implements a wrapper to the 'usleep()' function to provide the possibility to interrupt the sleep state by 'unlocking' the module instance handler.

Author
Rafael Antoniello

Definition in file interr_usleep.h.

Function Documentation

int interr_usleep ( interr_usleep_ctx_t interr_usleep_ctx,
uint32_t  usec 
)

Perform the interruptible 'usleep' operation; that is: suspends execution of the calling thread for (at least) usec microseconds. The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers.

Parameters
Pointerto the interruptible module instance context structure, that was obtained in a previous call to the 'interr_usleep_open()' function.
usecUnsigned 32-bit integer specifying the amount of microseconds to sleep.
Returns
Status code:
  • STAT_SUCCESS code in case of success;
  • STAT_EINTR in the case of interruption caused by a parallel call to 'interr_usleep_unblock()' function;
  • STAT_ERROR or other status code in the case of an internal error (refer to .stat_codes.h).

Definition at line 133 of file interr_usleep.c.

void interr_usleep_close ( interr_usleep_ctx_t **  ref_interr_usleep_ctx)

Unlock 'usleep' operation -if applicable- and release interruptible module instance context structure.

Parameters
ref_interr_usleep_ctxReference to the pointer to the interruptible module instance context structure to be release, that was obtained in a previous call to the 'interr_usleep_open()' function. Pointer is set to NULL on return.

Definition at line 102 of file interr_usleep.c.

interr_usleep_ctx_t* interr_usleep_open ( )

Initializes (open) interruptible module instance.

Returns
Pointer to the interruptible module instance context structure ("handler") on success, NULL if fails.

Definition at line 70 of file interr_usleep.c.

void interr_usleep_unblock ( interr_usleep_ctx_t interr_usleep_ctx)

Unlock 'usleep' operation.

Parameters
Pointerto the interruptible module instance context structure, that was obtained in a previous call to the 'interr_usleep_open()' function.

Definition at line 122 of file interr_usleep.c.