diff options
| author | Comment <tim@gray.(none)> | 2013-02-24 23:24:18 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-02-24 23:24:18 +0000 |
| commit | d5193b058ca06db9bda772ccdf49a8c4976c7274 (patch) | |
| tree | f555499bf462c2b0e1ea0f10b8a21035f1e1e091 | |
| parent | 9de16e3435b0e6fd14af991db278717387d676d3 (diff) | |
working threading
| -rwxr-xr-x | rotord/rotor.h | 13 | ||||
| -rwxr-xr-x | rotord/rotord.cpp | 10 | ||||
| -rwxr-xr-x | rotord/rotord.h | 5 |
3 files changed, 16 insertions, 12 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index b21673b..ac4532a 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -89,18 +89,17 @@ namespace Rotor { int num_performances; int num_clips; }; - class Render_context: public Poco::Runnable{ //Poco thread object + class Render_context: public Poco::Task{ //Poco task object //manages a 'patchbay' //high level interfaces for the wizard //and low level interface onto the graph public: - void run() { - printf("Rotor: starting thread\n"); - while (1) sleep(1); - - } - ~Render_context() { + Render_context(const std::string& name): Task(name) { + }; + void runTask() { + while (!isCancelled()) sleep(1); printf("Rotor: stopping thread\n"); + } Render_status get_status(); void cancel(); //interrupt locking process diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp index 1843c9c..cb106d0 100755 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -145,13 +145,15 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS if (command.size()) { if (command[0]=="new") { string sID=idGen.create().toString(); - context[sID]=Rotor::Render_context(); - pool.start(context[sID]); + printf("Rotor: starting thread\n"); + manager.start(new Rotor::Render_context(sID)); content="<sID>"+sID+"</sID>\n"; } else if (command[0]=="list") { - for (std::unordered_map<std::string,Rotor::Render_context>::iterator it = context.begin(); it != context.end(); ++it) { - content+="<sID>"+it->first+"</sID>\n"; + std::list < Poco::AutoPtr < Poco::Task > >::iterator it; + it=manager.taskList().begin(); + for (it=manager.taskList().begin();it !=manager.taskList().end();++it) { + content+="<sID>"+(*it)->name()+"</sID>\n"; } } else { diff --git a/rotord/rotord.h b/rotord/rotord.h index 472a879..b948577 100755 --- a/rotord/rotord.h +++ b/rotord/rotord.h @@ -11,6 +11,8 @@ #include "Poco/DateTimeFormat.h" #include "Poco/Exception.h" #include "Poco/ThreadPool.h" +#include "Poco/Task.h" +#include "Poco/TaskManager.h" #include "Poco/Util/ServerApplication.h" #include "Poco/Util/Option.h" #include "Poco/Util/OptionSet.h" @@ -32,6 +34,7 @@ using Poco::Timestamp; using Poco::DateTimeFormatter; using Poco::DateTimeFormat; using Poco::ThreadPool; +using Poco::TaskManager; using Poco::Util::ServerApplication; using Poco::Util::Application; using Poco::Util::Option; @@ -79,7 +82,7 @@ class RotorRequestHandlerFactory: public HTTPRequestHandlerFactory private: std::unordered_map<std::string,Rotor::Render_context> context; Poco::UUIDGenerator idGen; - Poco::ThreadPool pool; + Poco::TaskManager manager; }; class RotorServer: public Poco::Util::ServerApplication |
