Skip to content
Snippets Groups Projects

Move emper::sleep() implemention from header in compilation unit

Merged Florian Schmaus requested to merge flow/emper:emper-sleep-in-module into master
2 files
+ 19
14
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 2
13
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020 Florian Schmaus
// Copyright © 2020-2021 Florian Schmaus
#pragma once
#include <cassert>
@@ -10,7 +10,6 @@
#include "Fiber.hpp"
#include "Runtime.hpp"
#include "SynchronizedFiber.hpp"
#include "io/Future.hpp"
void async(Fiber* fiber) {
assert(fiber != nullptr);
@@ -75,16 +74,6 @@ void yield() {
runtime->yield();
}
auto sleep(unsigned int seconds) -> bool {
if constexpr (!emper::IO) {
DIE_MSG("sleep requires emper::io");
}
emper::io::AlarmFuture::Timespec ts = {.tv_sec = seconds, .tv_nsec = 0};
emper::io::AlarmFuture alarm(ts);
int32_t res = alarm.submitAndWait();
return res == -ETIME;
}
auto sleep(unsigned int seconds) -> bool;
} // namespace emper
Loading