Changeset 1276 for code/branches/console/src/core/TclThreadManager.cc
- Timestamp:
- May 15, 2008, 1:05:58 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/TclThreadManager.cc
r1269 r1276 58 58 ConsoleCommand(TclThreadManager, flush, AccessLevel::None, false); 59 59 60 TclThreadManager* instance = &TclThreadManager::getInstance();60 TclThreadManager* instance_tclthreadmanager = &TclThreadManager::getInstance(); 61 61 62 62 TclThreadManager::TclThreadManager() … … 92 92 COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().threadCounter_ << std::endl; 93 93 return TclThreadManager::getInstance().threadCounter_; 94 } 95 96 unsigned int TclThreadManager::createID(unsigned int threadID) 97 { 98 unsigned int temp = TclThreadManager::getInstance().threadCounter_; 99 TclThreadManager::getInstance().threadCounter_ = threadID - 1; 100 TclThreadManager::create(); 101 TclThreadManager::getInstance().threadCounter_ = temp; 102 return threadID; 94 103 } 95 104 … … 136 145 void TclThreadManager::execute(unsigned int threadID, const std::string& _command) 137 146 { 138 std::string command = _command; 139 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 140 command = command.substr(1, command.size() - 2); 141 147 std::string command = stripEnclosingBraces(_command); 142 148 143 149 if (threadID == 0) … … 237 243 void TclThreadManager::tcl_execute(Tcl::object const &args) 238 244 { 239 std::string command = args.get(); 240 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 241 command = command.substr(1, command.size() - 2); 242 243 TclThreadManager::getInstance().pushCommandToQueue(command); 245 TclThreadManager::getInstance().pushCommandToQueue(stripEnclosingBraces(args.get())); 244 246 } 245 247 246 248 std::string TclThreadManager::tcl_query(int querierID, Tcl::object const &args) 247 249 { 248 std::string command = args.get(); 249 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 250 command = command.substr(1, command.size() - 2); 251 252 return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, command); 250 return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, stripEnclosingBraces(args.get())); 253 251 } 254 252 255 253 std::string TclThreadManager::tcl_crossquery(int querierID, int threadID, Tcl::object const &args) 256 254 { 257 std::string command = args.get(); 258 while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}') 259 command = command.substr(1, command.size() - 2); 260 261 return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, command); 255 return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, stripEnclosingBraces(args.get())); 262 256 } 263 257 … … 349 343 350 344 this->forceCommandToFrontOfQueue("error " + error); 345 } 346 347 void TclThreadManager::debug(const std::string& error) 348 { 349 if (boost::this_thread::get_id() != this->threadID_) 350 { 351 boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_); 352 if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH) 353 { 354 boost::this_thread::yield(); 355 return; 356 } 357 } 358 359 this->forceCommandToFrontOfQueue("debug " + error); 351 360 } 352 361 … … 506 515 if (successfullyLocked) 507 516 { 517 this->debug("TclThread_query: " + command); 508 518 try 509 519 { output = (std::string)target->interpreter_->eval(command); } … … 566 576 void tclThread(TclInterpreterBundle* interpreterBundle, std::string command) 567 577 { 568 std::cout << "tclthreadm executes " << command << std::endl;578 TclThreadManager::getInstance().debug("TclThread_execute: " + command); 569 579 boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_); 570 580 try
Note: See TracChangeset
for help on using the changeset viewer.