summaryrefslogtreecommitdiff
path: root/Source/Kernel/TaskManager/Mutex.class.cpp
blob: 55226ff59be5b123ba3030eedd490d9a04e1f56e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "Mutex.class.h"
#include <TaskManager/Task.ns.h>

Mutex::Mutex(bool locked) {
	m_locked = locked;
}

bool Mutex::lock() {
	if (m_locked) return false;
	m_locked = true;
	return m_locked;
}

void Mutex::waitLock() {
	while (m_locked)
		Task::currentThread->sleep(10);	//Wait 10ms
	m_locked = true;
}

void Mutex::unlock() {
	m_locked = false;
}

bool Mutex::locked() {
	return m_locked;
}