From 33f286000db35fe50639c237caa736deea304585 Mon Sep 17 00:00:00 2001 From: johannst Date: Tue, 22 Sep 2020 23:48:09 +0200 Subject: split classes into separate files, add arch specific subdir --- lib/executor.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/executor.cc (limited to 'lib/executor.cc') diff --git a/lib/executor.cc b/lib/executor.cc new file mode 100644 index 0000000..fb79b49 --- /dev/null +++ b/lib/executor.cc @@ -0,0 +1,20 @@ +/* Copyright (c) 2020 Johannes Stoelp */ + +#include "executor.h" + +#include "arch/x86_64/asm.h" + +namespace nMatcha { + void Executor::spawn(std::unique_ptr t) { + mThreads.push_back(std::move(t)); + mThreads.back()->mExecutor = this; + } + + void Executor::run() { + for (const std::unique_ptr& t : mThreads) { + yield_to(t.get()); + } + } + + void Executor::yield_to(const Thread* t) const { ::yield(t->mStackPtr, &mStackPtr); } +} // namespace nMatcha -- cgit v1.2.3