aboutsummaryrefslogtreecommitdiff
path: root/lib/matcha.h
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2020-09-18 01:36:00 +0200
committerjohannst <johannes.stoelp@gmail.com>2020-09-18 01:36:00 +0200
commitd89c25701381b393839ff38f93f198c4105b2c21 (patch)
tree96b5a81b411ac1b158d9e9df6dac09063cd53fc1 /lib/matcha.h
parentec45be0578fb50ad4f3df28275f01d82a6d7b518 (diff)
downloadmatcha-threads-d89c25701381b393839ff38f93f198c4105b2c21.tar.gz
matcha-threads-d89c25701381b393839ff38f93f198c4105b2c21.zip
move yielding into Thread base class + make user fn a pure virtual fn and require user to derive from Thread
Diffstat (limited to 'lib/matcha.h')
-rw-r--r--lib/matcha.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/matcha.h b/lib/matcha.h
index 905107f..1506081 100644
--- a/lib/matcha.h
+++ b/lib/matcha.h
@@ -1,14 +1,18 @@
struct Thread {
Thread(const Thread&) = delete;
Thread& operator=(const Thread&) = delete;
- Thread(void (*fn)());
+ Thread();
- static void entry(void* obj);
+ virtual void threadFn() = 0;
+
+ // use from executor
+ void yield_to() const;
+
+ protected:
+ // use in thread
+ void yield();
- // private:
+ private:
+ static void entry(void* obj);
void* mStackPtr;
- void (*mUserFn)();
};
-
-void yield_to(const Thread& t);
-void yield_from(Thread& t);