6 #include <boost/container/flat_map.hpp>
7 #include <boost/thread/mutex.hpp>
45 boost::mutex::scoped_lock
lock(_mutex);
48 qiLogVerbose(
"qi.scopedfuturegroup") <<
"Trying to add non-cancelable future added to ScopedFutureGroup - future ignored.";
56 MemFuncType onFutureFinishedCallback = &ScopedFutureGroup::onFutureFinished<T>;
57 future.template thenR<void>(onFutureFinishedCallback,
this, _1);
64 FutureCancelList cancelList;
66 boost::mutex::scoped_lock
lock(_mutex);
67 swap(cancelList, _futureCancelList);
69 for (FutureCancelList::iterator it = cancelList.begin(), itEnd = cancelList.end();
76 catch (std::exception& ex)
78 qiLogWarning(
"qi.scopedfuturegroup") <<
"Failed to cancel scoped future: " << ex.what();
82 qiLogWarning(
"qi.scopedfuturegroup") <<
"Failed to cancel scoped future: unknown error.";
91 boost::mutex::scoped_lock
lock(_mutex);
92 return _futureCancelList.empty();
98 boost::mutex::scoped_lock
lock(_mutex);
99 return _futureCancelList.size();
103 mutable boost::mutex _mutex;
104 typedef boost::container::flat_map< FutureUniqueId, boost::function<void()> > FutureCancelList;
105 FutureCancelList _futureCancelList;
110 boost::mutex::scoped_lock
lock(_mutex);
111 _futureCancelList.erase(future.
uniqueId());
#define qiLogVerbose(...)
Log in verbose mode. This level is not shown by default.
boost::shared_ptr< ScopedFutureGroup > lock()
#define qiLogWarning(...)
Log in warning mode.
void swap(::qi::AnyFunction &a,::qi::AnyFunction &b)
bool isCancelable() const
void add(Future< T > future)
Object tracking by blocking destruction while shared pointers are present.
FutureUniqueId uniqueId() const