17 #ifndef THREADPOOL_DETAIL_FUTURE_IMPL_HPP_INCLUDED
18 #define THREADPOOL_DETAIL_FUTURE_IMPL_HPP_INCLUDED
23 #include <boost/smart_ptr.hpp>
24 #include <boost/optional.hpp>
25 #include <boost/thread/mutex.hpp>
26 #include <boost/thread/condition.hpp>
27 #include <boost/thread/xtime.hpp>
28 #include <boost/utility/result_of.hpp>
29 #include <boost/static_assert.hpp>
30 #include <boost/type_traits.hpp>
35 template<
class Result>
61 , m_is_cancelled(false)
72 const future_type*
self =
const_cast<const future_type*
>(
this);
73 mutex::scoped_lock
lock(self->m_monitor);
77 self->m_condition_ready.wait(lock);
84 const future_type*
self =
const_cast<const future_type*
>(
this);
85 mutex::scoped_lock
lock(self->m_monitor);
89 if(!self->m_condition_ready.timed_wait(lock, timestamp))
return false;
106 return *(
const_cast<const future_result_type*
>(&
m_result));
113 if(!m_ready && !m_is_cancelled)
135 if(!m_ready || m_executing)
137 m_is_cancelled =
true;
155 m_executing = executing;
161 template <
typename>
class Future,
186 : m_function(function)
195 m_future->set_execution_status(
true);
196 if(!m_future->is_cancelled())
201 m_future->set_execution_status(
false);
213 #endif // THREADPOOL_DETAIL_FUTURE_IMPL_HPP_INCLUDED
Result future_result_type
Indicates the future's result type.
Future< future_result_type > future_type
Indicates the future's type.
void set_value(future_result_type const &r) volatile
The namespace threadpool contains a thread pool and related utility classes.
Smart pointer with a scoped locking mechanism.
volatile future_result_type m_result
future_impl_task_func(function_type const &function, shared_ptr< future_type > const &future)
result_of< function_type()>::type future_result_type
Indicates the future's result type.
shared_ptr< future_type > m_future
Genfun::AbsFunction Function
void set_execution_status(bool executing) volatile
bool is_cancelled() const volatile
result_type operator()() const volatile
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
volatile bool m_executing
Result const & result_type
Indicates the functor's result type.
condition m_condition_ready
bool ready() const volatile
void result_type
Indicates the functor's result type.
future_impl< future_result_type > future_type
BOOST_STATIC_ASSERT(function_traits< function_type()>::arity==0)
Function function_type
Indicates the function's type.
volatile bool m_is_cancelled
void wait() const volatile
The locking_ptr is smart pointer with a scoped locking mechanism.
bool timed_wait(boost::xtime const ×tamp) const