#ifndef __MUTEX_LOCK_H
#define __MUTEX_LOCK_H

#include "xbt/synchro.h"

class MutexLock
{
public:
	MutexLock()
	{
		_lock = xbt_mutex_init();
	}
	~MutexLock()
	{
		xbt_mutex_destroy(_lock);
	}

	void lock()
	{
		xbt_mutex_lock(_lock);
	}

	void unlock()
	{
		xbt_mutex_unlock(_lock);
	}

private:
	
	xbt_mutex_t _lock;
};

class AutoMutextLock
{
public:
	AutoMutextLock(MutexLock &lock) : _lock(lock)
	{
		_lock.lock();
	}
	~AutoMutextLock()
	{
		_lock.unlock();
	}

private:
	MutexLock& _lock;
};


#endif // __MUTEX_LOCK_H