From afeb81fb97b8ee4e50a3679707deb17e5b79a74f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 19 Jul 2012 13:37:35 +0300 Subject: [PATCH] Make wait applicable to all task types --- source/externaltask.h | 2 +- source/internaltask.cpp | 7 +++++++ source/internaltask.h | 1 + source/task.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/externaltask.h b/source/externaltask.h index a5f10ec..19ffe71 100644 --- a/source/externaltask.h +++ b/source/externaltask.h @@ -45,7 +45,7 @@ public: virtual std::string get_command() const; virtual void start(); virtual Status check(); - Status wait(); + virtual Status wait(); private: Status do_wait(bool); diff --git a/source/internaltask.cpp b/source/internaltask.cpp index b8cbf11..c117bad 100644 --- a/source/internaltask.cpp +++ b/source/internaltask.cpp @@ -22,6 +22,13 @@ Task::Status InternalTask::check() return worker->get_status(); } +Task::Status InternalTask::wait() +{ + Status result; + while((result = worker->get_status())==RUNNING) ; + return result; +} + InternalTask::Worker::Worker(): status(RUNNING) diff --git a/source/internaltask.h b/source/internaltask.h index f29a61d..399e119 100644 --- a/source/internaltask.h +++ b/source/internaltask.h @@ -35,6 +35,7 @@ public: virtual std::string get_command() const { return ""; } virtual void start(); virtual Status check(); + virtual Status wait(); }; #endif diff --git a/source/task.h b/source/task.h index 1f59473..9cf2bac 100644 --- a/source/task.h +++ b/source/task.h @@ -28,6 +28,7 @@ public: virtual std::string get_command() const = 0; virtual void start() = 0; virtual Status check() = 0; + virtual Status wait() = 0; }; #endif -- 2.45.2