From 1c25cbe0f11e62c32dae8d615f988a08866c5015 Mon Sep 17 00:00:00 2001 From: Sangwan Kwon Date: Thu, 9 Jan 2020 14:39:58 +0900 Subject: [PATCH] Apply timeout to ondemand service Signed-off-by: Sangwan Kwon --- src/vist/rmi/impl/general/server.hpp | 5 ++++- src/vist/rmi/impl/ondemand/server.hpp | 4 ++-- src/vist/rmi/impl/server.hpp | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vist/rmi/impl/general/server.hpp b/src/vist/rmi/impl/general/server.hpp index 0a6f898..05d256e 100644 --- a/src/vist/rmi/impl/general/server.hpp +++ b/src/vist/rmi/impl/general/server.hpp @@ -51,8 +51,11 @@ public: Server(Server&&) = default; Server& operator=(Server&&) = default; - void run() override + /// boost-based service does not support timeout and stopper. + void run(int timeout = -1, interface::Stopper stopper = nullptr) override { + (void) timeout; + (void) stopper; this->context.run(); } diff --git a/src/vist/rmi/impl/ondemand/server.hpp b/src/vist/rmi/impl/ondemand/server.hpp index 5a898e6..154bb10 100644 --- a/src/vist/rmi/impl/ondemand/server.hpp +++ b/src/vist/rmi/impl/ondemand/server.hpp @@ -60,9 +60,9 @@ public: Server(Server&&) = default; Server& operator=(Server&&) = default; - void run(void) override + void run(int timeout = -1, interface::Stopper stopper = nullptr) override { - this->mainloop.run(); + this->mainloop.run(timeout, stopper); } void stop(void) override diff --git a/src/vist/rmi/impl/server.hpp b/src/vist/rmi/impl/server.hpp index 948d0c0..cb56f90 100644 --- a/src/vist/rmi/impl/server.hpp +++ b/src/vist/rmi/impl/server.hpp @@ -27,6 +27,7 @@ namespace impl { namespace interface { using Task = std::function; +using Stopper = std::function; class Server { public: @@ -39,7 +40,7 @@ public: Server(Server&&) = default; Server& operator=(Server&&) = default; - virtual void run() = 0; + virtual void run(int timeout = -1, Stopper stopper = nullptr) = 0; virtual void stop() = 0; private: -- 2.34.1