#ifndef __ASYNC_WATCHACTION_HPP__ #define __ASYNC_WATCHACTION_HPP__ #include #include #include #include "proto/rpc.grpc.pb.h" #include "etcd/v3/Action.hpp" #include "etcd/v3/AsyncWatchResponse.hpp" #include "etcd/Response.hpp" using grpc::ClientAsyncReaderWriter; using etcdserverpb::WatchRequest; using etcdserverpb::WatchResponse; namespace etcdv3 { class AsyncWatchAction : public etcdv3::Action { public: AsyncWatchAction(etcdv3::ActionParameters const ¶m); AsyncWatchResponse ParseResponse(); void waitForResponse(); void waitForResponse(std::function callback); void CancelWatch(); void WatchReq(std::string const & key); bool Cancelled() const; private: WatchResponse reply; std::unique_ptr> stream; std::atomic_bool isCancelled; std::mutex protect_is_cancalled; }; } #endif