diff options
author | johannst <johannes.stoelp@gmail.com> | 2020-10-05 23:03:03 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2020-10-05 23:03:03 +0200 |
commit | 2c4330e7c01cf404406dd3380e64304460b29b02 (patch) | |
tree | 588bbbd660e16c45d3578fea988b9566cf9b3387 /lib/executor.h | |
parent | abba364fb3b8871a2baac7779b0850b3bdc479b0 (diff) | |
download | matcha-threads-2c4330e7c01cf404406dd3380e64304460b29b02.tar.gz matcha-threads-2c4330e7c01cf404406dd3380e64304460b29b02.zip |
added doc on thread & executor
Diffstat (limited to 'lib/executor.h')
-rw-r--r-- | lib/executor.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/executor.h b/lib/executor.h index f04f3f1..0f2eca9 100644 --- a/lib/executor.h +++ b/lib/executor.h @@ -8,16 +8,26 @@ #include <memory> namespace nMatcha { + // Cooperative user thread scheduler. + // + // The executor is responsible to schedule the next user thread after one + // thread yielded, as long as there are user threads that didn't finish. + // + // When a `Thread` instance is spawned on an `Executor`, its ownership is + // transfered to the executor. + // struct Executor { Executor(const Executor&) = delete; Executor& operator=(const Executor&) = delete; Executor() = default; - const void* getStackPtr() const { - return mStackPtr; - } + const void* getStackPtr() const; + // Spawn an user thread on the executor. void spawn(std::unique_ptr<Thread> t); + + // Run the executor until all user threads are finished. + // This example executor implements round robin scheduling. void run(); private: |