#pragma once

#include "ehs/EHS.h"
#include "ehs/Str.h"
#include "BaseSemaphore.h"

#include <semaphore.h>

namespace ehs
{
	class EHS_LIB_IO Semaphore : public BaseSemaphore
	{
	private:
		sem_t hdl;
		bool valid;

	public:
		~Semaphore();

		Semaphore();

		Semaphore(const Str_8& name, const UInt_32 initial);

		Semaphore(const UInt_32 initial);

		Semaphore(Semaphore&& sem) noexcept;

		Semaphore(const Semaphore& sem);

		Semaphore& operator=(Semaphore&& sem) noexcept;

		Semaphore& operator=(const Semaphore& sem);

		void Initialize() override;

		void Release() override;

		bool Wait(const UInt_32 timeout) override;

		void Signal(const UInt_32 inc) override;

		bool IsValid() const override;
	};
}