#ifndef GPK_CHANNEL
# define GPK_CHANNEL
# include <thread.h>
# include <synch.h>
# include <string.h>


class generic_channel	{
	mutex_t mutex;
	cond_t data_available;
	cond_t data_empty;
	const void *data;
	int sz;

	public:

	void read(void *p, int sz);
	void write(const void *p, int sz);
	generic_channel();
	~generic_channel();
	};

template <class T>
class channel : private generic_channel	{
	public:
	void write(const T *p)	{ generic_channel::write((const void *)p, sizeof(T));}
	void read(T *p)	{ generic_channel::read((void *)p, sizeof(T));}
	};

#endif
