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/matcha.h | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 lib/matcha.h (limited to 'lib/matcha.h') diff --git a/lib/matcha.h b/lib/matcha.h deleted file mode 100644 index 5843cb7..0000000 --- a/lib/matcha.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2020 Johannes Stoelp */ - -#include -#include - -struct Executor; - -struct Thread { - Thread(const Thread&) = delete; - Thread& operator=(const Thread&) = delete; - Thread(); - virtual ~Thread() {} - - virtual void threadFn() = 0; - - protected: - void yield(); - - private: - static void entry(void* obj); - void* mStackPtr; - - friend struct Executor; - const Executor* mExecutor; -}; - - -struct Executor { - Executor(const Executor&) = delete; - Executor& operator=(const Executor&) = delete; - Executor() = default; - - const void* getStackPtr() const { return mStackPtr; } - - void spawn(std::unique_ptr t) { - mThreads.push_back(std::move(t)); - mThreads.back()->mExecutor = this; - } - void run() { - for (const std::unique_ptr& t : mThreads) { - yield_to(t.get()); - } - } - - private: - void* mStackPtr; - std::vector> mThreads; - - void yield_to(const Thread* t) const; -}; -- cgit v1.2.3