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 /example/demo1.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 'example/demo1.cc')
-rw-r--r-- | example/demo1.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/example/demo1.cc b/example/demo1.cc new file mode 100644 index 0000000..1c910cd --- /dev/null +++ b/example/demo1.cc @@ -0,0 +1,33 @@ +/* Copyright (c) 2020 Johannes Stoelp */ + +#include "lib/executor.h" +#include "lib/thread.h" + +#include <cstdio> +#include <memory> + +struct TestThread : public nMatcha::Thread { + TestThread(const char* name) : Thread(), mName(name) {} + + virtual void threadFn() override { + printf("[%s] starting up TestThread -> yield()\n", mName); + yield(); + printf("[%s] yield() -> finishing TestThreads\n", mName); + } + + private: + const char* mName; +}; + +int main() { + puts("[main] start main thread"); + + nMatcha::Executor e; + e.spawn(std::make_unique<TestThread>("Thread1")); + e.spawn(std::make_unique<TestThread>("Thread2")); + e.spawn(std::make_unique<TestThread>("Thread3")); + e.run(); + + puts("[main] finish main thread"); + return 0; +} |