7 #ifndef __FWTHREAD_WORKER_HXX__ 8 #define __FWTHREAD_WORKER_HXX__ 10 #include <fwThread/TaskHandler.hpp> 19 template<
typename R,
typename TASK >
22 std::packaged_task< R() > task( f );
23 std::future< R > ufuture = task.get_future();
25 std::function< void() > ftask = ::fwThread::moveTaskIntoFunction(task);
36 return std::move(ufuture);
41 #endif // __FWTHREAD_WORKER_HXX__ std::shared_future< R > postTask(CALLABLE f)
Requests invocation of the given callable and returns a shared future.
FWTHREAD_API ThreadIdType getCurrentThreadId()
Returns the current thread id.
virtual void post(TaskType handler)=0
Requests invocation of the given task handler and returns immediately.
virtual FWTHREAD_API ThreadIdType getThreadId() const =0
Returns the worker's thread id.
This namespace fwThread provides few tools to execute asynchronous tasks on different threads...