7 #define BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS 9 #include "fwJobs/Job.hpp" 11 #include "fwJobs/exception/Waiting.hpp" 13 #include <fwThread/Worker.hpp> 14 #include <fwThread/Worker.hxx> 16 #include <boost/scope_exit.hpp> 27 return std::make_shared<Job>( name, task, worker );
51 auto jobTask = [ = ]()
53 BOOST_SCOPE_EXIT_ALL( = )
64 return m_worker->postTask<
void >( jobTask );
76 return ::std::async( []() {} );
96 return [
this](std::uint64_t
doneWork)
FWJOBS_API SharedFuture runImpl()
Run the task of the job and mark the job as finished.
std::uint64_t m_totalWorkUnits
Number of work units to reach to complete the job.
FWJOBS_API ProgressCallback progressCallback()
Return a job callback with the done work number as parameter This callback can only be used if the jo...
FWJOBS_API void doneWork(std::uint64_t units)
Setter on done work units.
FWJOBS_API std::function< void() > finishCallback()
Return callback to finish the job.
This class is an interface for class managing job.
virtual FWJOBS_API SharedFuture cancel()
Cancel the current job and call all available cancel callbacks.
std::shared_future< void > SharedFuture
Future type.
::boost::unique_lock< ReadWriteMutex > WriteLock
Defines a lock of write type for read/write mutex.
virtual FWJOBS_API SharedFuture cancel()
Reimplements IJob's cancel.
mutable::fwCore::mt::ReadWriteMutex m_mutex
Mutex to protect object access.
FWJOBS_API std::shared_ptr< ::fwThread::Worker > getWorker()
Getter on the current job worker or nullptr if no worker has been set.
FWJOBS_API Job(const std::string &name, Task task, const std::shared_ptr< ::fwThread::Worker > &worker=nullptr)
Construct a new job.
static FWJOBS_API sptr New(const std::string &name, Task task, const std::shared_ptr< ::fwThread::Worker > &worker=nullptr)
Construct a new job and return a smart pointer of it.
std::function< void(Job &) > Task
Task type.
This namespace fwJobs provides jobs management.
std::shared_ptr< ::fwJobs::Job > sptr
Task type.
virtual FWJOBS_API void finish()
Finish the job: set state to finished or canceled.
std::function< void(std::uint64_t) > ProgressCallback
Progress callback type.