roo_threads
API Documentation for roo_threads
Loading...
Searching...
No Matches
semaphore.h
Go to the documentation of this file.
1#pragma once
2
4#include "roo_time.h"
5
6#ifdef ROO_THREADS_SINGLETHREADED
7
8#include "roo_backport.h"
9#include "roo_backport/move.h"
10
11namespace roo_threads {
12/// @brief Backend namespace for single-threaded synchronization fallbacks.
13namespace singlethreaded {
14
15template <std::ptrdiff_t LeastMaxValue =
16 std::numeric_limits<std::ptrdiff_t>::max()>
17/// @ingroup roo_threads_api_semaphore
18/// @brief Single-threaded backend implementation of `roo::counting_semaphore`.
19/// @copydoc roo_threads::doc::counting_semaphore
20class counting_semaphore {
21 public:
22 counting_semaphore() noexcept = default;
23 counting_semaphore(const counting_semaphore&) = delete;
24 counting_semaphore& operator=(const counting_semaphore&) = delete;
25
26 /// @copydoc roo_threads::doc::counting_semaphore::acquire
27 void acquire() noexcept {}
28 /// @copydoc roo_threads::doc::counting_semaphore::release
29 void release() noexcept {}
30};
31
32/// @ingroup roo_threads_api_semaphore
33/// @brief Single-threaded backend implementation of `roo::binary_semaphore`.
34/// @copydoc roo_threads::doc::binary_semaphore
35using binary_semaphore = counting_semaphore<1>;
36
37} // namespace singlethreaded
38} // namespace roo_threads
39
40#endif // ROO_THREADS_USE_CPPSTD
counting_semaphore< 1 > binary_semaphore
Semaphore with maximum count of one.