// Common, group WinWrap
// see CW Semaphore
// Copyright Alexander Liss

#ifndef __SEMAPHORE_H__
#define __SEMAPHORE_H__

#include "kernel.h"

// acquire a "slot" through a wait function

class Semaphore: public Kernel 
{
public:
	// creates or opens a semaphore object
Semaphore( int nInitialCount, int nMaximumCount, LPCTSTR name = 0, LPSECURITY_ATTRIBUTES lpSA = 0);

	// opens an existing named semaphore
	// check the status 
Semaphore( LPCTSTR name, BOOL bInheritHandle = FALSE, DWORD dwDesiredAccess = SEMAPHORE_ALL_ACCESS);

	// release the "slot"
BOOL release( LONG& previous_count, LONG release_count=1  );
BOOL creator(){return attributes & 1;}
private:
	DWORD attributes;
};



#endif