8#ifndef OCM_DAQ_OP_INITIATE_HPP_
9#define OCM_DAQ_OP_INITIATE_HPP_
10#include "../config.hpp"
17#include <boost/thread/future.hpp>
41template <class Op, class R = decltype(std::declval<Op&>().Initiate()),
class... Params>
60template <class Op, class R = decltype(std::declval<Op&>().Initiate()),
class... Params>
61std::pair<R, std::function<
bool()>>
67template <
class Op,
class R,
class... Params>
69 std::unique_ptr<Op> op = std::make_unique<Op>(std::forward<Params>(params)...);
73 return ptr->Initiate().then(ex, [op = std::move(op)](
auto f) {
return f.get(); });
76template <
class Op,
class R,
class... Params>
77std::pair<R, std::function<bool()>>
81 std::shared_ptr<Op> op = std::make_shared<Op>(std::forward<Params>(params)...);
83 auto weak = std::weak_ptr<Op>(op);
85 ptr->Initiate().then(ex, [op = std::move(op)](
auto f) {
return f.get(); }),
86 [weak = std::move(weak)]()
mutable ->
bool {
87 if (
auto op = weak.lock(); op) {
Adapts boost::asio::io_context into a compatible boost::thread Executor type.
R InitiateOperation(rad::IoExecutor &ex, Params &&... params)
Constructs and initiates Op and return the future result.
std::pair< R, std::function< bool()> > InitiateAbortableOperation(rad::IoExecutor &ex, Params &&... params)
Like InitiateOperation but in addition to returning the future it also returns an unspecified object ...