6#ifdef ROO_THREADS_SINGLETHREADED
11namespace singlethreaded {
24 id(
int id) : id_(id) {}
26 bool operator==(
const id& other)
const {
return id_ == other.id_; }
34 thread() noexcept = default;
36 thread(const thread&) = delete;
39 thread(thread&& other) noexcept { swap(other); }
45 template <
typename Callable,
typename... Args>
46 explicit thread(Callable&& callable, Args&&... args);
51 thread& operator=(
const thread&) =
delete;
54 thread& operator=(thread&& other)
noexcept =
default;
57 void swap(thread& other)
noexcept { std::swap(id_, other.id_); }
60 bool joinable() const noexcept {
return !(id_ == id()); }
71 thread::id
get_id() const noexcept {
return id_; }
77namespace this_thread {
81inline thread::id
get_id() noexcept {
return thread::id(1); }
90inline
void sleep_for(const roo_time::Duration& duration) {
91 if (duration.inMicros() <= 0)
return;
92 roo_time::Delay(duration);
97inline void sleep_until(
const roo_time::Uptime& when) {
98 return sleep_for(when - roo_time::Uptime::Now());
thread::id get_id() noexcept
Returns identifier of the current thread.
void yield() noexcept
Hints the scheduler to run another thread.
void sleep_until(const roo_time::Uptime &when)
Blocks the current thread until the specified time point.
void sleep_for(const roo_time::Duration &duration)
Blocks the current thread for at least the given duration.