MediaProcessors
Classes | Macros | Typedefs | Functions
interr_usleep.c File Reference
#include "interr_usleep.h"
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
#include "log.h"
#include "stat_codes.h"
#include "check_utils.h"
Include dependency graph for interr_usleep.c:

Go to the source code of this file.

Classes

struct  interr_usleep_ctx_s
 

Macros

#define UNLOCK()
 

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

Author
Rafael Antoniello

Definition in file interr_usleep.c.

Macro Definition Documentation

#define UNLOCK ( )
Value:
interr_usleep_ctx->flag_exit= 1; \
pthread_mutex_lock(&interr_usleep_ctx->interr_mutex); \
pthread_cond_broadcast(&interr_usleep_ctx->interr_signal); \
pthread_mutex_unlock(&interr_usleep_ctx->interr_mutex);

MACRO used to unlock internal MUTEX: sets exit flag and send signal to eventually unlock MUTEX

Definition at line 60 of file interr_usleep.c.

Typedef Documentation

Interruptible usleep context structure.

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.