#ifndef __OS_MUTEX_H
#define __OS_MUTEX_H

#include <sys/types.h>
#include <cpp/Uncopyable.h>
#include <kernel/Dispatcher.h>
#include <kernel/Spinlock.h>

namespace OS {

class Thread;

class Mutex : private Uncopyable {
public:
	Mutex();
	~Mutex();

	status_t Acquire();
	status_t Release();

private:
	Thread *mHolder;
	Kernel::Dispatcher mDispatcher;
};

class AutoMutex : private Uncopyable {
public:
	AutoMutex(Mutex &lock) : mLock(lock) { mLock.Acquire(); }
	~AutoMutex() { mLock.Release(); }

private:
	Mutex &mLock;
};

} // namespace OS
	
#endif

