Xyris
0.5
Mutex.hpp
Go to the documentation of this file.
1
/**
2
* @file Mutex.hpp
3
* @author Keeton Feavel (
[email protected]
)
4
* @brief
5
* @version 0.3
6
* @date 2020-08-30
7
*
8
* @copyright Copyright the Xyris Contributors (c) 2020
9
*
10
*/
11
#pragma once
12
13
#include <stdint.h>
14
#include <
Scheduler/tasks.hpp
>
15
16
class
Mutex
{
17
public
:
18
/**
19
* @brief Construct a new Mutex object
20
*
21
* @param name Mutex name (for debugging / printing)
22
*/
23
Mutex
(
const
char
* name =
nullptr
);
24
25
/**
26
* @brief Aquire the mutex.
27
*
28
* @return int Returns true on success.
29
*/
30
bool
lock
();
31
32
/**
33
* @brief Try to aquire the mutex and return immediately
34
* if already locked.
35
*
36
* @return int Returns true on success.
37
*/
38
bool
tryLock
();
39
40
/**
41
* @brief Release the mutex.
42
*
43
* @return int Returns true on success.
44
*/
45
bool
unlock
();
46
47
private
:
48
bool
m_isLocked
;
49
struct
task_sync
m_taskSync
;
50
};
Mutex::unlock
bool unlock()
Release the mutex.
Definition:
Mutex.cpp:38
Mutex::m_isLocked
bool m_isLocked
Definition:
Mutex.hpp:48
tasks.hpp
task_sync
Definition:
tasks.hpp:55
Mutex::m_taskSync
struct task_sync m_taskSync
Definition:
Mutex.hpp:49
Mutex
Definition:
Mutex.hpp:16
Mutex::lock
bool lock()
Aquire the mutex.
Definition:
Mutex.cpp:20
Mutex::Mutex
Mutex(const char *name=nullptr)
Construct a new Mutex object.
Definition:
Mutex.cpp:13
Mutex::tryLock
bool tryLock()
Try to aquire the mutex and return immediately if already locked.
Definition:
Mutex.cpp:29
Kernel
Locking
Mutex.hpp
Generated by
1.8.17