aboutsummaryrefslogtreecommitdiff
path: root/lib/thread.cc
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2020-10-05 17:57:26 +0200
committerjohannst <johannes.stoelp@gmail.com>2020-10-05 17:57:26 +0200
commit40335c667870e72deb739b81ffbf8d23902ebe71 (patch)
treef98587f320ec85f3d912430454e51e1acf99c04f /lib/thread.cc
parente710fae8b8a1c34109644e5991f293b58e7eaa16 (diff)
downloadmatcha-threads-40335c667870e72deb739b81ffbf8d23902ebe71.tar.gz
matcha-threads-40335c667870e72deb739b81ffbf8d23902ebe71.zip
add support for function objects
Diffstat (limited to 'lib/thread.cc')
-rw-r--r--lib/thread.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/thread.cc b/lib/thread.cc
index 31161ab..e6777c0 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -56,4 +56,10 @@ namespace nMatcha {
assert(mExecutor);
::yield(mExecutor->getStackPtr(), &mStackPtr);
}
+
+ std::unique_ptr<Thread> FnThread::make(UserFn f) { return std::make_unique<FnThread>(CreatorToken{}, f); }
+
+ void FnThread::threadFn() { mUserFn(*this); }
+
+ void FnThread::yield() { Thread::yield(); }
} // namespace nMatcha