6 #include <boost/container/flat_map.hpp>
7 #include <boost/thread/mutex.hpp>
42 boost::mutex::scoped_lock lock(_mutex);
43 _futureCancelList.emplace(future.
uniqueId(), [future]()
mutable { future.
cancel(); });
53 FutureCancelList cancelList;
55 boost::mutex::scoped_lock lock(_mutex);
56 swap(cancelList, _futureCancelList);
58 for (FutureCancelList::iterator it = cancelList.begin(), itEnd = cancelList.end();
65 catch (std::exception& ex)
67 qiLogWarning(
"qi.scopedfuturegroup") <<
"Failed to cancel scoped future: " << ex.what();
71 qiLogWarning(
"qi.scopedfuturegroup") <<
"Failed to cancel scoped future: unknown error.";
80 boost::mutex::scoped_lock lock(_mutex);
81 return _futureCancelList.empty();
87 boost::mutex::scoped_lock lock(_mutex);
88 return _futureCancelList.size();
92 mutable boost::mutex _mutex;
93 using FutureCancelList = boost::container::flat_map< FutureUniqueId, boost::function<void()>>;
94 FutureCancelList _futureCancelList;
99 boost::mutex::scoped_lock lock(_mutex);
100 _futureCancelList.erase(future.
uniqueId());
#define qiLogWarning(...)
Log in warning mode.
void swap(::qi::AnyFunction &a,::qi::AnyFunction &b)
auto then(FutureCallbackType type, AF &&func) -> qi::Future< typename detail::DecayAsyncResult< AF, qi::Future< T >>::type >
Execute a callback when the future is finished.
void add(Future< T > future)
Object tracking by blocking destruction while shared pointers are present.
FutureUniqueId uniqueId() const