12#include <Poco/Thread.h>
28 : m_threadnum(threadnum), m_scheduler(scheduler), m_prog(prog), m_waitSec(waitSec) {
30 throw std::invalid_argument(
"NULL ThreadScheduler passed to ThreadPoolRunnable::ctor()");
42 std::shared_ptr<Task> task;
46 Poco::Thread::sleep(10);
57 std::shared_ptr<std::mutex> mutex = task->getMutex();
64 }
catch (std::exception &e) {
87 Poco::Thread::sleep(10);
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
double m_waitSec
How many seconds you are allowed to wait with no tasks before exiting.
void run() override
Thread method.
void clearWait()
Clear the wait time of the runnable so that it stops waiting for tasks.
size_t m_threadnum
ID of this thread.
ProgressBase * m_prog
Progress reporter.
ThreadScheduler * m_scheduler
The ThreadScheduler instance taking care of task scheduling.
ThreadPoolRunnable(size_t threadnum, ThreadScheduler *scheduler, ProgressBase *prog=nullptr, double waitSec=0.0)
Constructor.
The ThreadScheduler object defines how tasks are allocated to threads and in what order.
virtual void abort(std::runtime_error exception)
Signal to the scheduler that a task is complete.
virtual void finished(Task *task, size_t threadnum)
Signal to the scheduler that a task is complete.
virtual std::shared_ptr< Task > pop(size_t threadnum)=0
Retrieves the next Task to execute.
virtual bool empty()=0
Returns true if the queue is empty.