6 #include <boost/container/flat_map.hpp>
7 #include <boost/thread/synchronized_value.hpp>
42 _futureCancelList->emplace(future.
uniqueId(), [future]()
mutable { future.
cancel(); });
50 FutureCancelList cancelList;
52 auto synched_futureCancelList = _futureCancelList.synchronize();
53 swap(cancelList, *synched_futureCancelList);
55 for (
auto& slot : cancelList)
61 catch (std::exception& ex)
63 qiLogWarning(
"qi.scopedfuturegroup") <<
"Failed to cancel scoped future: " << ex.what();
67 qiLogWarning(
"qi.scopedfuturegroup") <<
"Failed to cancel scoped future: unknown error.";
76 return _futureCancelList->empty();
82 return _futureCancelList->size();
87 using FutureCancelList = boost::container::flat_map< FutureUniqueId, boost::function<void()>>;
88 boost::synchronized_value<FutureCancelList> _futureCancelList;
93 _futureCancelList->erase(future.
uniqueId());
auto track(F &&f, T &&toTrack) -> decltype(trackWithFallback(detail::throwPointerLockException, std::forward< F >(f), std::forward< T >(toTrack)))
#define qiLogWarning(...)
Log in warning mode.
auto then(FutureCallbackType type, F &&func) -> Future< typename std::result_of< F(Future< T >)>::type >
Execute a callback when the future is finished.
void swap(::qi::AnyFunction &a,::qi::AnyFunction &b)
void add(Future< T > future)
Object tracking by blocking destruction while shared pointers are present.
FutureUniqueId uniqueId() const