Changeset 1269 for code/branches
- Timestamp:
- May 14, 2008, 12:46:00 AM (17 years ago)
- Location:
- code/branches/console
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/bin/remote.tcl
r1267 r1269 1 TclThreadManager create 2 TclThreadManager execute 1source telnet_server.tcl1 set telnetserverthreadid [TclThreadManager create] 2 TclThreadManager execute $telnetserverthreadid source telnet_server.tcl -
code/branches/console/src/core/CommandExecutor.cc
r1255 r1269 394 394 if (useTcl) 395 395 { 396 std::string temp = getLowercase(removeTrailingWhitespaces(command));397 if (!(temp.find("tclthread") == 0 || temp.find("tclthreadmanager") == 0))396 // std::string temp = getLowercase(removeTrailingWhitespaces(command)); 397 // if (!(temp.substr(0, 16) == "tclthreadmanager" || temp.substr(0, 10) == "tclexecute" || temp.substr(0, 8) == "tclquery")) 398 398 return TclBind::eval(command); 399 399 } -
code/branches/console/src/core/InputBuffer.cc
r1230 r1269 39 39 { 40 40 //this->bActivated_ = false; 41 this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^~ ";41 this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#"; 42 42 this->keyboard_ = InputManager::getSingleton().getKeyboard(); 43 43 this->buffer_ = ""; -
code/branches/console/src/core/TclThreadManager.cc
r1267 r1269 48 48 namespace orxonox 49 49 { 50 // ConsoleCommand(TclThreadManager, tclthread, AccessLevel::None, true); 50 ConsoleCommandShortcutGeneric(tclexecute, createExecutor(createFunctor(&TclThreadManager::execute), "tclexecute", AccessLevel::None)); 51 ConsoleCommandShortcutGeneric(tclquery, createExecutor(createFunctor(&TclThreadManager::query), "tclquery", AccessLevel::None)); 51 52 ConsoleCommand(TclThreadManager, create, AccessLevel::None, false); 52 53 ConsoleCommand(TclThreadManager, destroy, AccessLevel::None, false); 53 54 ConsoleCommand(TclThreadManager, execute, AccessLevel::None, false); 54 55 ConsoleCommand(TclThreadManager, query, AccessLevel::None, false); 55 // ConsoleCommand(TclThreadManager, status, AccessLevel::None, false); 56 // ConsoleCommand(TclThreadManager, dump, AccessLevel::None, false); 56 ConsoleCommand(TclThreadManager, status, AccessLevel::None, false); 57 ConsoleCommand(TclThreadManager, dump, AccessLevel::None, false); 58 ConsoleCommand(TclThreadManager, flush, AccessLevel::None, false); 57 59 58 60 TclThreadManager* instance = &TclThreadManager::getInstance(); … … 132 134 } 133 135 134 void TclThreadManager::execute(unsigned int threadID, const std::string& command) 135 { 136 TclThreadManager::getInstance().pushCommandToQueue(threadID, command); 136 void TclThreadManager::execute(unsigned int threadID, const std::string& _command) 137 { 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 142 143 if (threadID == 0) 144 TclThreadManager::getInstance().pushCommandToQueue(command); 145 else 146 TclThreadManager::getInstance().pushCommandToQueue(threadID, command); 137 147 } 138 148 … … 140 150 { 141 151 return TclThreadManager::getInstance().evalQuery(TclThreadManager::getInstance().orxonoxInterpreterBundle_.id_, threadID, command); 152 } 153 154 void TclThreadManager::status() 155 { 156 COUT(0) << "Thread ID" << '\t' << "Queue size" << '\t' << "State" << std::endl; 157 158 std::string output = "Orxonox"; 159 output += "\t\t"; 160 { 161 boost::mutex::scoped_lock queue_lock(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queueMutex_); 162 output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size()); 163 } 164 output += "\t\t"; 165 output += "busy"; 166 COUT(0) << output << std::endl; 167 168 boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_); 169 for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = TclThreadManager::getInstance().interpreterBundles_.begin(); it != TclThreadManager::getInstance().interpreterBundles_.end(); ++it) 170 { 171 std::string output = getConvertedValue<unsigned int, std::string>((*it).first); 172 output += "\t\t"; 173 { 174 boost::mutex::scoped_lock queue_lock((*it).second->queueMutex_); 175 output += getConvertedValue<unsigned int, std::string>((*it).second->queue_.size()); 176 } 177 output += "\t\t"; 178 { 179 boost::mutex::scoped_lock interpreter_lock((*it).second->interpreterMutex_, boost::defer_lock_t()); 180 if (interpreter_lock.try_lock()) 181 output += "ready"; 182 else 183 output += "busy"; 184 } 185 COUT(0) << output << std::endl; 186 } 187 } 188 189 void TclThreadManager::dump(unsigned int threadID) 190 { 191 TclInterpreterBundle* bundle = 0; 192 if (threadID == 0) 193 { 194 bundle = &TclThreadManager::getInstance().orxonoxInterpreterBundle_; 195 COUT(0) << "Queue dump of Orxonox:" << std::endl; 196 } 197 else 198 { 199 if (bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID)) 200 { 201 COUT(0) << "Queue dump of Tcl-thread " << threadID << ":" << std::endl; 202 } 203 else 204 return; 205 } 206 207 boost::mutex::scoped_lock queue_lock(bundle->queueMutex_); 208 unsigned int index = 0; 209 for (std::list<std::string>::const_iterator it = bundle->queue_.begin(); it != bundle->queue_.end(); ++it) 210 { 211 index++; 212 COUT(0) << index << ": " << (*it) << std::endl; 213 } 214 } 215 216 void TclThreadManager::flush(unsigned int threadID) 217 { 218 TclInterpreterBundle* bundle = 0; 219 if (threadID == 0) 220 bundle = &TclThreadManager::getInstance().orxonoxInterpreterBundle_; 221 else 222 if (!(bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID))) 223 return; 224 225 boost::mutex::scoped_lock queue_lock(bundle->queueMutex_); 226 bundle->queue_.clear(); 227 if (threadID == 0) 228 { 229 COUT(0) << "Flushed queue of Orxonox Tcl-interpreter." << std::endl; 230 } 231 else 232 { 233 COUT(0) << "Flushed queue of Tcl-interpreter " << threadID << "." << std::endl; 234 } 142 235 } 143 236 … … 473 566 void tclThread(TclInterpreterBundle* interpreterBundle, std::string command) 474 567 { 568 std::cout << "tclthreadm executes " << command << std::endl; 475 569 boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_); 476 570 try -
code/branches/console/src/core/TclThreadManager.h
r1257 r1269 76 76 static void execute(unsigned int threadID, const std::string& command); 77 77 static std::string query(unsigned int threadID, const std::string& command); 78 static void status(); 79 static void dump(unsigned int threadID); 80 static void flush(unsigned int threadID); 78 81 79 82 static void tcl_execute(Tcl::object const &args);
Note: See TracChangeset
for help on using the changeset viewer.