stm32rcos
読み取り中…
検索中…
一致する文字列を見つけられません
include
stm32rcos
core
mutex.hpp
[詳解]
1
#pragma once
2
3
#include <cstdint>
4
#include <memory>
5
#include <type_traits>
6
7
#include <cmsis_os2.h>
8
9
namespace
stm32rcos
{
10
namespace
core
{
11
12
class
Mutex
{
13
private
:
14
struct
Deleter {
15
void
operator()(osMutexId_t mutex_id) { osMutexDelete(mutex_id); }
16
};
17
18
using
MutexId = std::unique_ptr<std::remove_pointer_t<osMutexId_t>, Deleter>;
19
20
public
:
21
Mutex
(uint32_t attr_bits = 0) {
22
osMutexAttr_t attr{};
23
attr.attr_bits = attr_bits;
24
mutex_id_ = MutexId{osMutexNew(&attr)};
25
}
26
27
bool
try_lock
(uint32_t timeout) {
28
return
osMutexAcquire(mutex_id_.get(), timeout) == osOK;
29
}
30
31
void
lock
() {
try_lock
(osWaitForever); }
32
33
void
unlock
() { osMutexRelease(mutex_id_.get()); }
34
35
private
:
36
MutexId mutex_id_;
37
};
38
39
}
// namespace core
40
}
// namespace stm32rcos
stm32rcos::core::Mutex::unlock
void unlock()
Definition
mutex.hpp:33
stm32rcos::core::Mutex::lock
void lock()
Definition
mutex.hpp:31
stm32rcos::core::Mutex::Mutex
Mutex(uint32_t attr_bits=0)
Definition
mutex.hpp:21
stm32rcos::core::Mutex::try_lock
bool try_lock(uint32_t timeout)
Definition
mutex.hpp:27
stm32rcos::core
Definition
mutex.hpp:10
stm32rcos
Definition
mutex.hpp:9
構築:
1.13.2