|
Boost : |
Subject: [boost] [threadpool] draft n2276 - interrupting tasks
From: k-oli_at_[hidden]
Date: 2008-11-22 11:38:54
Hello,
the draft specifies that the threapool::submit() function returns a future
object in order to retrieve the result of the submited task.
What about task cancelation/interruption?
Instead returning a future the pool could return a task< R > object which
contains a future< R > (access over R task< R >::get()) and interruption
routines.
boost.threadpool in the boost vault implements somthing like:
task< R > threadpool::submit(...);
template< typename R >
class task
{
...
// interrupt task and return immediatly
void interrupt();
// interrupt task and wait till it's finished
void interrupt_and_wait();
// interrupt task and wait a certain time till it's finished or timeout
template< typename TimeDuration >
void interrupt_and_wait( TimeDuration const& td);
// interrupt task and wait to a specific system time till it's finished or
timeout
void interrupt_and_wait( system_time const& st);
bool interrupt_requested();
R get()
{ return impl_fut_->get(); }
bool ready() const
{ return impl_fut_->ready(); }
bool has_value() const;
bool has_exception() const;
};
Following Herb Sutters sugestions the submited task must be cooperative
(contain interruption_point).
What do you think? Should/Could it be added to the draft?
regards,
Oliver
{ return impl_fut_->has_exception(); }
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk