From: Mikko Rasa Date: Thu, 10 May 2012 21:19:35 +0000 (+0300) Subject: Don't start tasks automatically upon creation X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b5ccba555f4985233532041c34e28d71dd58933f;p=builder.git Don't start tasks automatically upon creation --- diff --git a/source/builder.cpp b/source/builder.cpp index 9fdb8ee..9dfa2e6 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -584,7 +584,10 @@ int Builder::do_build() IO::print("%-4s %s\n", tgt->get_tool()->get_tag(), tgt->get_name()); Task *task = tgt->build(); if(task) + { + task->start(); tasks.push_back(task); + } if(show_progress) IO::print("%d of %d target%s built\033[1G", count, total, (total!=1 ? "s" : "")); diff --git a/source/copy.cpp b/source/copy.cpp index 30ab60e..5b524a4 100644 --- a/source/copy.cpp +++ b/source/copy.cpp @@ -35,9 +35,7 @@ Task *Copy::run(const Target &target) const Copy::Worker::Worker(const InstalledFile &t): target(t) -{ - launch(); -} +{ } void Copy::Worker::main() { diff --git a/source/externaltask.cpp b/source/externaltask.cpp index c205cbc..672762b 100644 --- a/source/externaltask.cpp +++ b/source/externaltask.cpp @@ -11,6 +11,9 @@ using namespace Msp; ExternalTask::ExternalTask(const vector &argv, const FS::Path &work_dir): pid(-1), exit_code(-1) +{ } + +void ExternalTask::start() { if((pid = fork())) { diff --git a/source/externaltask.h b/source/externaltask.h index 1701313..3028e74 100644 --- a/source/externaltask.h +++ b/source/externaltask.h @@ -15,6 +15,7 @@ private: public: ExternalTask(const std::vector &, const Msp::FS::Path &); + virtual void start(); virtual Status check(); }; diff --git a/source/internaltask.cpp b/source/internaltask.cpp index 4293203..37c9b75 100644 --- a/source/internaltask.cpp +++ b/source/internaltask.cpp @@ -9,6 +9,11 @@ InternalTask::~InternalTask() delete worker; } +void InternalTask::start() +{ + worker->launch(); +} + Task::Status InternalTask::check() { if(worker->get_status()!=RUNNING) diff --git a/source/internaltask.h b/source/internaltask.h index ea25ba8..9e52247 100644 --- a/source/internaltask.h +++ b/source/internaltask.h @@ -9,6 +9,8 @@ class InternalTask: public Task public: class Worker: public Msp::Thread { + friend class InternalTask; + protected: Status status; @@ -25,6 +27,7 @@ public: InternalTask(Worker *); ~InternalTask(); + virtual void start(); virtual Status check(); }; diff --git a/source/pkgconfiggenerator.cpp b/source/pkgconfiggenerator.cpp index 555d8c5..b18402a 100644 --- a/source/pkgconfiggenerator.cpp +++ b/source/pkgconfiggenerator.cpp @@ -28,9 +28,7 @@ Task *PkgConfigGenerator::run(const Target &target) const PkgConfigGenerator::Worker::Worker(const PkgConfig &t): target(t) -{ - launch(); -} +{ } void PkgConfigGenerator::Worker::main() { diff --git a/source/tar.cpp b/source/tar.cpp index b49e6fe..49b4c08 100644 --- a/source/tar.cpp +++ b/source/tar.cpp @@ -38,9 +38,7 @@ Task *Tar::run(const Target &target) const Tar::Worker::Worker(const TarBall &tb): tarball(tb) -{ - launch(); -} +{ } void Tar::Worker::main() { diff --git a/source/task.h b/source/task.h index d2cf5a4..03d212b 100644 --- a/source/task.h +++ b/source/task.h @@ -20,6 +20,7 @@ protected: public: virtual ~Task() { } + virtual void start() = 0; virtual Status check() = 0; };