Changeset 1255 for code/branches/console/src/core/TclThreadManager.h
- Timestamp:
- May 12, 2008, 2:50:21 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/TclThreadManager.h
r1247 r1255 31 31 32 32 #include <queue> 33 #include <map> 34 #include <list> 33 35 34 36 #include <boost/thread/mutex.hpp> … … 43 45 class boost::thread; 44 46 45 struct TclThread47 struct _CoreExport TclInterpreterBundle 46 48 { 47 unsigned int threadID_; 49 unsigned int id_; 50 51 std::list<std::string> queue_; 52 boost::mutex queueMutex_; 53 48 54 Tcl::interpreter* interpreter_; 49 boost::thread* thread_; 50 boost::mutex* evalMutex_; 51 boost::mutex* stateMutex_; 52 enum State 53 { 54 Ready, 55 Busy, 56 Finished, 57 Error 58 }* state_; 55 std::string interpreterName_; 56 boost::try_mutex interpreterMutex_; 57 58 std::list<unsigned int> queriers_; 59 boost::mutex queriersMutex_; 60 61 bool running_; 62 boost::mutex runningMutex_; 63 64 bool finished_; 65 boost::mutex finishedMutex_; 66 boost::condition finishedCondition_; 59 67 }; 60 68 … … 64 72 static TclThreadManager& getInstance(); 65 73 66 static void tclthread(unsigned int threadID, const std::string& command);67 74 static unsigned int create(); 68 75 static void destroy(unsigned int threadID); 69 76 static void execute(unsigned int threadID, const std::string& command); 70 77 static std::string query(unsigned int threadID, const std::string& command); 71 static void status();72 static void dump(unsigned int threadID);73 78 74 static std::string tcl_query(int id, Tcl::object const &args);75 79 static void tcl_execute(Tcl::object const &args); 80 static std::string tcl_query(int querierID, Tcl::object const &args); 81 static std::string tcl_crossquery(int querierID, int threadID, Tcl::object const &args); 82 static bool tcl_running(int threadID); 76 83 77 Tcl::interpreter* create TclInterpreter(unsigned int threadID) const;78 bool createTclThread();79 bool destroyTclThread(unsigned int threadID);84 Tcl::interpreter* createNewTclInterpreter(const std::string& threadID); 85 TclInterpreterBundle* getInterpreterBundle(unsigned int threadID); 86 std::string dumpList(const std::list<unsigned int>& list); 80 87 81 void setState(TclThread* tclThread, TclThread::State state); 82 TclThread::State getState(TclThread* tclThread); 88 void pushCommandToQueue(const std::string& command); 89 void forceCommandToFrontOfQueue(const std::string& command); 90 std::string popCommandFromQueue(); 91 bool queueIsEmpty(); 83 92 84 void pushCommand Back(const std::string& command);85 std::string popCommandFro nt();86 bool isEmpty();93 void pushCommandToQueue(unsigned int threadID, const std::string& command); 94 std::string popCommandFromQueue(unsigned int threadID); 95 bool queueIsEmpty(unsigned int threadID); 87 96 88 void pushCommandBack(unsigned int threadID, const std::string& command); 89 std::string popCommandFront(unsigned int threadID); 90 bool isEmpty(unsigned int threadID); 97 bool updateQueriersList(TclInterpreterBundle* querier, TclInterpreterBundle* target); 91 98 92 std::string eval (const std::string& command);93 std::string eval (unsigned int threadID, const std::string& command);99 std::string evalQuery(unsigned int querierID, const std::string& command); 100 std::string evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command); 94 101 95 102 virtual void tick(float dt); … … 97 104 private: 98 105 TclThreadManager(); 106 TclThreadManager(const TclThreadManager& other); 107 ~TclThreadManager() {} 99 108 100 bool isReady_; 101 bool isQuerying_; 102 unsigned int queryID_; 103 104 unsigned int IDcount_; 105 std::map<unsigned int, TclThread*> threads_; 106 std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> > threadQueues_; 107 std::queue<std::string> orxonoxQueue_; 108 109 boost::try_mutex orxonoxQueueMutex_; 110 boost::try_mutex threadQueuesMutex_; 111 boost::try_mutex threadsMutex_; 112 boost::try_mutex orxonoxStateMutex_; 113 boost::try_mutex orxonoxQueryMutex_; 114 115 boost::condition orxonoxQueueCondition_; 109 unsigned int threadCounter_; 110 TclInterpreterBundle orxonoxInterpreterBundle_; 111 std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_; 112 boost::mutex bundlesMutex_; 113 boost::condition fullQueueCondition_; 116 114 boost::condition orxonoxEvalCondition_; 117 115 }; 118 116 119 _CoreExport void tclThread Loop(TclThread* tclThread);117 _CoreExport void tclThread(TclInterpreterBundle* interpreterBundle, std::string command); 120 118 } 121 119
Note: See TracChangeset
for help on using the changeset viewer.