diff options
author | johannst <johannes.stoelp@gmail.com> | 2020-09-22 23:48:09 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2020-09-22 23:48:09 +0200 |
commit | 33f286000db35fe50639c237caa736deea304585 (patch) | |
tree | ddb74ebd1f626b200cbb5050545ded484dde4787 /lib/executor.cc | |
parent | 488d4c6237c3f713077fe93e2745ba5defde0aa5 (diff) | |
download | matcha-threads-33f286000db35fe50639c237caa736deea304585.tar.gz matcha-threads-33f286000db35fe50639c237caa736deea304585.zip |
split classes into separate files, add arch specific subdir
Diffstat (limited to 'lib/executor.cc')
-rw-r--r-- | lib/executor.cc | 20 |
1 files changed, 20 insertions, 0 deletions
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<Thread> t) { + mThreads.push_back(std::move(t)); + mThreads.back()->mExecutor = this; + } + + void Executor::run() { + for (const std::unique_ptr<Thread>& t : mThreads) { + yield_to(t.get()); + } + } + + void Executor::yield_to(const Thread* t) const { ::yield(t->mStackPtr, &mStackPtr); } +} // namespace nMatcha |