diff --git a/src/clientmon.cpp b/src/clientmon.cpp index d4f1aaf..03633e9 100644 --- a/src/clientmon.cpp +++ b/src/clientmon.cpp @@ -177,6 +177,14 @@ struct SubscriptionImpl : public OperationBase, public Subscription return std::shared_ptr(self); } + virtual void onEvent(std::function&& fn) override final { + decltype (event) junk; + loop.call([this, &junk, &fn]() { + junk = std::move(event); + this->event = std::move(fn); + }); + } + virtual bool cancel() override final { decltype (event) junk; bool ret; diff --git a/src/pvxs/client.h b/src/pvxs/client.h index 4c67f1b..b606a62 100644 --- a/src/pvxs/client.h +++ b/src/pvxs/client.h @@ -199,6 +199,10 @@ public: */ virtual Value pop() =0; + // Expert API + // replace handler stored with MonitorBuilder::event() + virtual void onEvent(std::function&&) =0; + //! Return strong internal reference which will not prevent //! implicit cancellation when the last reference returned //! by exec() is released.