8 #ifndef OCM_DAQ_OP_INITIATE_HPP_
9 #define OCM_DAQ_OP_INITIATE_HPP_
10 #include "../config.hpp"
14 #include <type_traits>
17 #include <boost/thread/future.hpp>
39 template<class Op, class R=decltype(std::declval<Op&>().Initiate()),
class... Params>
58 template<class Op, class R=decltype(std::declval<Op&>().Initiate()),
class... Params>
65 template <
class Op,
class R,
class... Params>
67 std::unique_ptr<Op> op = std::make_unique<Op>(std::forward<Params>(params)...);
71 return ptr->Initiate().then(boost::launch::inherit, [op = std::move(op)](
auto f) {
return f.get(); });
74 template <
class Op,
class R,
class... Params>
78 std::shared_ptr<Op> op = std::make_shared<Op>(std::forward<Params>(params)...);
80 auto weak = std::weak_ptr<Op>(op);
82 ptr->Initiate().then(boost::launch::inherit,
83 [op = std::move(op)](
auto f) {
return f.get(); }),
84 [weak = std::move(weak)]()
mutable ->
bool {
85 if (
auto op = weak.lock(); op) {
97 #endif // #ifndef OCM_DAQ_OP_INITIATE_HPP_