Skip to content
Snippets Groups Projects
Commit 65880e12 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Move all definitions from emper.hpp in compilation unit

parent 2cae4faf
No related branches found
No related tags found
1 merge request!232Move all definitions from emper.hpp in compilation unit
......@@ -2,16 +2,46 @@
// Copyright © 2020-2021 Florian Schmaus
#include "Emper.hpp"
#include <cassert>
#include <cerrno>
#include <cstdint>
#include <stdexcept>
#include <utility>
#include "Common.hpp"
#include "Fiber.hpp"
#include "Runtime.hpp"
#include "emper-common.h"
#include "emper-version.h"
#include "emper.hpp"
#include "io/Future.hpp"
void async(Fiber* fiber) {
assert(fiber != nullptr);
Runtime* runtime = Runtime::getRuntime();
runtime->schedule(*fiber);
}
void async(Fiber::fiber_fun_t function, void* arg) {
Fiber* fiber = Fiber::from(std::move(function), arg);
async(fiber);
}
void async(const Fiber::fiber_fun0_t& function) {
Fiber* fiber = Fiber::from(function);
async(fiber);
}
void async(Fiber::fiber_fun_t function, void* arg, workeraffinity_t* affinity) {
Fiber* fiber = Fiber::from(std::move(function), arg, affinity);
async(fiber);
}
void async(const Fiber::fiber_fun0_t& function, workeraffinity_t* affinity) {
Fiber* fiber = Fiber::from(function, affinity);
async(fiber);
}
namespace emper {
auto getFullVersion() -> std::string { return EMPER_FULL_VERSION; }
......@@ -48,6 +78,11 @@ void destroy_runtime() {
delete runtime;
}
void yield() {
Runtime* runtime = Runtime::getRuntime();
runtime->yield();
}
auto sleep(unsigned int seconds) -> bool {
if constexpr (!emper::IO) {
DIE_MSG("sleep requires emper::io");
......
......@@ -11,31 +11,15 @@
#include "Runtime.hpp"
#include "SynchronizedFiber.hpp"
void async(Fiber* fiber) {
assert(fiber != nullptr);
Runtime* runtime = Runtime::getRuntime();
runtime->schedule(*fiber);
}
void async(Fiber* fiber);
void async(Fiber::fiber_fun_t function, void* arg) {
Fiber* fiber = Fiber::from(std::move(function), arg);
async(fiber);
}
void async(Fiber::fiber_fun_t function, void* arg);
void async(const Fiber::fiber_fun0_t& function) {
Fiber* fiber = Fiber::from(function);
async(fiber);
}
void async(const Fiber::fiber_fun0_t& function);
void async(Fiber::fiber_fun_t function, void* arg, workeraffinity_t* affinity) {
Fiber* fiber = Fiber::from(std::move(function), arg, affinity);
async(fiber);
}
void async(Fiber::fiber_fun_t function, void* arg, workeraffinity_t* affinity);
void async(const Fiber::fiber_fun0_t& function, workeraffinity_t* affinity) {
Fiber* fiber = Fiber::from(function, affinity);
async(fiber);
}
void async(const Fiber::fiber_fun0_t& function, workeraffinity_t* affinity);
template <typename S>
void spawn(Fiber::fiber_fun_t function, void* arg, S& semaphore) {
......@@ -69,10 +53,7 @@ void init_runtime(workerid_t worker_count);
void destroy_runtime();
void yield() {
Runtime* runtime = Runtime::getRuntime();
runtime->yield();
}
void yield();
auto sleep(unsigned int seconds) -> bool;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment