//	CriticalSection.h - Simple class representing a critical section.
//  ----------------------------------------------------------------------------

#ifndef CRITICALSECTION_H_
#define CRITICALSECTION_H_

typedef struct SDL_semaphore SDL_sem;

///	Simple class representing a critical section.
class CriticalSection
{
  public:
	///	Constructor.
	CriticalSection();
	///	Destructor.
	~CriticalSection();

	///	(Waits until the critical section is free and) Locks the Critical Section.
	/*!
		\return True if it was successfully locked, false otherwise.
	 */
	bool lock();
	///	Unlocks the critical section.
	void unlock();
  private:
	///	The SDL semaphore this critical section is based on.
	SDL_sem *semaphore;
};

#endif
