
#ifndef _JL_ProtectedObject_H_
#define _JL_ProtectedObject_H_

#include <stdlib.h>
#include <iostream.h>

#include "universal_threads.h"

class ProtectedObject {

	private:
		UNIV_SEMA	_sema;

	public: 
		ProtectedObject();
		ProtectedObject(const ProtectedObject &P) { CopyFrom(P); }
		virtual ~ProtectedObject();

		ProtectedObject& CopyFrom(const ProtectedObject&);
		ProtectedObject& operator=(const ProtectedObject &P)
				{ return CopyFrom(P); }

		void Lock() { if UNIV_SEMA_VALID(_sema) UNIV_HOLD_SEMA(_sema); }
		void UnLock() { if UNIV_SEMA_VALID(_sema) UNIV_RELEASE_SEMA(_sema); }
};

#endif
