/**
 * @file condvar.h
 * @brief Header file of file condvar.c
 * 
 * Conditional variables are implemented as a queue of threads vaiting for the condition, that allows 
 * to wakeup them on cond_wait and cond signal calls.
 * 
 * This file is based on Kalisto, Development Kernel copyrighted (c) to 
 * Distributed Systems Research Group MFF UK, Czech republic.
 */


#ifndef _CONDVAR_H_
#define _CONDVAR_H_ 

#include "mutex.h"
#include "tqueue.h"
#include "thread.h"

/** structure of conditional variable */
struct cond {
	/** queue to strore threads waiting on this conditional variable */
	thread_queue_t tq;
};

/** define conditional variable to usual notation with .._t */
typedef struct cond cond_t;

void cond_init (cond_t * cvar);
void cond_destroy (cond_t * cvar);
void cond_signal (cond_t * cvar);
void cond_broadcast (cond_t * cvar);
void cond_wait (cond_t * cvar, struct mutex* mtx);
int cond_wait_timeout (cond_t * cvar, mutex_t * mtx, const unsigned int usec);


#endif /*CONDVAR_H_*/
