aboutsummaryrefslogtreecommitdiff
path: root/lib/executor.h
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2020-09-22 23:48:09 +0200
committerjohannst <johannes.stoelp@gmail.com>2020-09-22 23:48:09 +0200
commit33f286000db35fe50639c237caa736deea304585 (patch)
treeddb74ebd1f626b200cbb5050545ded484dde4787 /lib/executor.h
parent488d4c6237c3f713077fe93e2745ba5defde0aa5 (diff)
downloadmatcha-threads-33f286000db35fe50639c237caa736deea304585.tar.gz
matcha-threads-33f286000db35fe50639c237caa736deea304585.zip
split classes into separate files, add arch specific subdir
Diffstat (limited to 'lib/executor.h')
-rw-r--r--lib/executor.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/executor.h b/lib/executor.h
new file mode 100644
index 0000000..5d2e5b6
--- /dev/null
+++ b/lib/executor.h
@@ -0,0 +1,27 @@
+/* Copyright (c) 2020 Johannes Stoelp */
+
+#pragma once
+
+#include "thread.h"
+
+#include <memory>
+#include <vector>
+
+namespace nMatcha {
+ struct Executor {
+ Executor(const Executor&) = delete;
+ Executor& operator=(const Executor&) = delete;
+ Executor() = default;
+
+ const void* getStackPtr() const { return mStackPtr; }
+
+ void spawn(std::unique_ptr<Thread> t);
+ void run();
+
+ private:
+ void* mStackPtr;
+ std::vector<std::unique_ptr<Thread>> mThreads;
+
+ void yield_to(const Thread* t) const;
+ };
+} // namespace nMatcha