7 #include "fwJobs/Observer.hpp" 16 return std::make_shared<Observer>( name, workUnits );
42 return [
this](std::uint64_t
doneWork)
static FWJOBS_API sptr New(const std::string &name, std::uint64_t workUnits=100)
Create a new Observer sptr with a name.
std::uint64_t m_totalWorkUnits
Number of work units to reach to complete the job.
std::function< void(std::uint64_t) > ProgressCallback
Progress callback type.
virtual FWJOBS_API SharedFuture runImpl()
Runs the task.
State m_state
Job's state.
FWJOBS_API void doneWork(std::uint64_t units)
Setter on done work units.
This class is an interface for class managing job.
std::shared_future< void > SharedFuture
Future type.
::boost::unique_lock< ReadWriteMutex > WriteLock
Defines a lock of write type for read/write mutex.
PackagedTask m_finishTask
Task observed.
std::packaged_task< void() > PackagedTask
Task type.
FWJOBS_API void finish()
Call for finishing observer progress.
FWJOBS_API Observer(const std::string &name, std::uint64_t workUnits=100)
Constructor.
FWJOBS_API void addSimpleCancelHook(CancelHook callback)
Add cancel callback to sequence for cancel hook.
mutable::fwCore::mt::ReadWriteMutex m_mutex
Mutex to protect object access.
::boost::shared_lock< ReadWriteMutex > ReadLock
Defines a lock of read type for read/write mutex.
FWJOBS_API void finishNoLock()
Finish the job without mutex lock: set the state to finished or canceled.
std::shared_ptr< ::fwJobs::Observer > sptr
Progress callback type.
FWJOBS_API SharedFuture run()
Run the current job.
This namespace fwJobs provides jobs management.
FWJOBS_API ProgressCallback progressCallback()
return a progress Callback function. This function takes work units in parameter. ...