struct osip_cond * osip_cond_init () { osip_cond_t *cond = (osip_cond_t *) osip_malloc (sizeof (osip_cond_t)); if ( (cond->sem = osip_sem_init (0))!=NULL) { return (struct osip_cond *) (cond); } osip_free (cond); return NULL; }
/* always use this method to initiate osip_fifo_t. */ void osip_fifo_init (osip_fifo_t * ff) { #ifdef OSIP_MT ff->qislocked = osip_mutex_init (); /*INIT SEMA TO BLOCK ON GET() WHEN QUEUE IS EMPTY */ ff->qisempty = osip_sem_init (0); #endif osip_list_init (&ff->queue); /* ff->nb_elt = 0; */ ff->state = osip_empty; }
/* always use this method to initiate osip_fifo_t. */ void osip_fifo_init (osip_fifo_t * ff) { #ifdef OSIP_MT ff->qislocked = osip_mutex_init (); /*INIT SEMA TO BLOCK ON GET() WHEN QUEUE IS EMPTY */ ff->qisempty = osip_sem_init (0); #endif ff->queue = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (ff->queue); /* ff->nb_elt = 0; */ ff->etat = vide; }
struct osip_cond * osip_cond_init () { osip_cond_t *cond = (osip_cond_t *) osip_malloc (sizeof (osip_cond_t)); if (cond && (cond->mut = osip_mutex_init ()) != NULL) { cond->sem = osip_sem_init (0); /* initially locked */ return (struct osip_cond *) (cond); } osip_free (cond); return NULL; }