Simple tools for multi threading / objects in plain C Snapshot
Classes | Typedefs | Functions
tqueue.c File Reference
#include "tqueue.h"
#include <errno.h>
#include <stdio.h>
#include <butils/errorp.h>

Go to the source code of this file.

Classes

struct  tagTQUEUE_Entry

Typedefs

typedef struct tagTQUEUE_Entry TQUEUE_Entry

Functions

int TQUEUE_init (TQUEUE *queue, size_t max_count)
 create new queue
int TQUEUE_free (TQUEUE *queue)
 destroy queue
static int push_entry (DLIST *lst, void *data)
int TQUEUE_push_exit_message (TQUEUE *queue)
 push out of order exit message (null message at top of queue)
int TQUEUE_push_block_on_queue_full (TQUEUE *queue, void *entry)
 add new entry to queue, block if maximum queue limit has been reached
int TQUEUE_push_fail_on_queue_full (TQUEUE *queue, void *entry)
 add new entry to queue, fail if maximum queue limit has been reached
int TQUEUE_pop_non_blocking (TQUEUE *queue, void **rret)
 pop queue, return error if empty. Does not block if queue is empty.
void * TQUEUE_pop (TQUEUE *queue)
 pop queue, block if empty

Typedef Documentation

typedef struct tagTQUEUE_Entry TQUEUE_Entry

Function Documentation

static int push_entry ( DLIST *  lst,
void *  data 
) [static]

Definition at line 35 of file tqueue.c.

{
  TQUEUE_Entry *entry = (TQUEUE_Entry *) malloc( sizeof(TQUEUE_Entry) );
  if (!entry) {
    return -1;
  }
  entry->entry = data;
  DLIST_push_front( lst, (DLIST_entry *) entry );
  return 0;
}