//	Zinc Application Framework - Z_SEM.HPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#if !defined(Z_SEM_HPP)
#define Z_SEM_HPP
#include <z_env.hpp>

// --------------------------------------------------------------------------
// ----- ZafSemaphore -----------------------------------------------------------
// --------------------------------------------------------------------------

enum ZafSemaphoreType
{
	ZAF_MUTEX_SEMAPHORE	= 0,
	ZAF_BINARY_SEMAPHORE	= 1,
	ZAF_COUNTING_SEMAPHORE	= 2
};

enum ZafSemaphoreOption
{
	ZAF_FIFO_SEMAPHORE	= 0,
	ZAF_PRIORITY_SEMAPHORE	= 1
};

typedef ZafInt8 ZafSemaphoreState;
const ZafSemaphoreState ZAF_TAKEN_SEMAPHORE			= -2;
const ZafSemaphoreState ZAF_AVAILABLE_SEMAPHORE			= -1;

typedef ZafInt16 ZafSemaphoreWait;
const ZafSemaphoreWait ZAF_NO_WAIT_SEMAPHORE			= -2;
const ZafSemaphoreWait ZAF_WAIT_FOREVER_SEMAPHORE		= -1;

class ZAF_EXPORT ZafSemaphore
{
public:
	// --- General members ---
	ZafSemaphore(ZafSemaphoreType semType, ZafSemaphoreOption semOption,
		ZafInt8 initialState = ZAF_AVAILABLE_SEMAPHORE);
	virtual ~ZafSemaphore(void);

	// --- Attributes & data access ---
	ZafError Give(void);
	ZafError Take(ZafInt16 wait);

protected:
	// --- General members ---
	OSSemaphoreID semID;
};

#endif // Z_SEM_HPP
