/*     
 * $RCSfile: xk_fifo.h,v $
 *
 * x-kernel v3.3
 *
 * Copyright (c) 1993,1991,1990,1996  Arizona Board of Regents
 *
 * $Log: xk_fifo.h,v $
 * Revision 1.1  1997/03/11  20:47:08  dorgival
 * Initial revision
 *
 * Revision 1.1  1997/03/11 20:47:08  dorgival
 * Initial revision
 *
 *
 */

#ifndef __fifo_h__
#define __fifo_h__

/*
 * This module provides a FIFO queueing service with mutual exclusion.
 * It has both a blocking and a non-blocking dequeue operation.
 */

#include "/usr/include/pthread.h"

typedef struct FIFO 	xk_fifo_t;
typedef struct FIFOEl *	FIFOEl;

struct FIFO {
    FIFOEl	    head;
    FIFOEl	    tail;
    int             nqueued;
    int             nblocked;
    pthread_mutex_t mutex;
    pthread_cond_t  cond;
};

struct FIFOEl {
    FIFOEl	next;
};

extern void	xkFifoInit     (xk_fifo_t* q);
extern int	xkFifoAppend   (xk_fifo_t* q, void *element);
extern void *	xkFifoRemove   (xk_fifo_t* q);
extern void *	xkFifoNBRemove (xk_fifo_t* q);

/* fifoAppend returns TRUE if a thread was waked to handle the newly queued
 * element, and FALSE otherwise.
 */

#endif /* __fifo_h__ */
