Apply timeout to ondemand service
authorSangwan Kwon <sangwan.kwon@samsung.com>
Thu, 9 Jan 2020 05:39:58 +0000 (14:39 +0900)
committer권상완/Security 2Lab(SR)/Engineer/삼성전자 <sangwan.kwon@samsung.com>
Tue, 14 Jan 2020 01:57:30 +0000 (10:57 +0900)
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
src/vist/rmi/impl/general/server.hpp
src/vist/rmi/impl/ondemand/server.hpp
src/vist/rmi/impl/server.hpp

index 0a6f898..05d256e 100644 (file)
@@ -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();
        }
 
index 5a898e6..154bb10 100644 (file)
@@ -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
index 948d0c0..cb56f90 100644 (file)
@@ -27,6 +27,7 @@ namespace impl {
 namespace interface {
 
 using Task = std::function<Message(Message&)>;
+using Stopper = std::function<bool(void)>;
 
 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: