From 40335c667870e72deb739b81ffbf8d23902ebe71 Mon Sep 17 00:00:00 2001 From: johannst Date: Mon, 5 Oct 2020 17:57:26 +0200 Subject: add support for function objects --- lib/thread.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/thread.cc') 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 FnThread::make(UserFn f) { return std::make_unique(CreatorToken{}, f); } + + void FnThread::threadFn() { mUserFn(*this); } + + void FnThread::yield() { Thread::yield(); } } // namespace nMatcha -- cgit v1.2.3