#include <src/core/TclThreadManager.h>
Public Member Functions | |
void | debug (const std::string &error) |
void | error (const std::string &error) |
std::list< unsigned int > | getThreadList () const |
TclThreadManager (Tcl::interpreter *interpreter) | |
void | update (const Clock &time) |
~TclThreadManager () | |
Static Public Member Functions | |
static unsigned int | create () |
static unsigned int | createID (unsigned int threadID) |
static void | destroy (unsigned int threadID) |
static void | dump (unsigned int threadID) |
static void | execute (unsigned int threadID, const std::string &command) |
static void | flush (unsigned int threadID) |
static TclThreadManager & | getInstance () |
static std::string | query (unsigned int threadID, const std::string &command) |
static void | status () |
Private Member Functions | |
Tcl::interpreter * | createNewTclInterpreter (const std::string &threadID) |
std::string | dumpList (const std::list< unsigned int > &list) |
std::string | evalQuery (unsigned int querierID, unsigned int threadID, const std::string &command) |
std::string | evalQuery (unsigned int querierID, const std::string &command) |
void | forceCommandToFrontOfQueue (const std::string &command) |
TclInterpreterBundle * | getInterpreterBundle (unsigned int threadID) |
Tcl::interpreter * | getTclInterpreter (unsigned int threadID) |
std::string | popCommandFromQueue (unsigned int threadID) |
std::string | popCommandFromQueue () |
void | pushCommandToQueue (unsigned int threadID, const std::string &command) |
void | pushCommandToQueue (const std::string &command) |
bool | queueIsEmpty (unsigned int threadID) |
bool | queueIsEmpty () |
TclThreadManager (const TclThreadManager &other) | |
bool | updateQueriersList (TclInterpreterBundle *querier, TclInterpreterBundle *target) |
Static Private Member Functions | |
static std::string | tcl_crossquery (int querierID, int threadID, Tcl::object const &args) |
static void | tcl_execute (Tcl::object const &args) |
static std::string | tcl_query (int querierID, Tcl::object const &args) |
static bool | tcl_running (int threadID) |
Private Attributes | |
std::map< unsigned int, TclInterpreterBundle * > | interpreterBundles_ |
TclInterpreterBundle * | orxonoxInterpreterBundle_ |
unsigned int | threadCounter_ |
Static Private Attributes | |
static TclThreadManager * | singletonRef_s = 0 |
Friends | |
class | IRC |
class | TclBind |
orxonox::TclThreadManager::TclThreadManager | ( | Tcl::interpreter * | interpreter | ) |
orxonox::TclThreadManager::~TclThreadManager | ( | ) |
References orxonox::bundlesMutex_g, destroy(), interpreterBundles_, orxonoxInterpreterBundle_, and singletonRef_s.
orxonox::TclThreadManager::TclThreadManager | ( | const TclThreadManager & | other | ) | [private] |
unsigned int orxonox::TclThreadManager::create | ( | ) | [static] |
References orxonox::bundlesMutex_g, COUT, createNewTclInterpreter(), getInstance(), interpreterBundles_, orxonox::multi_cast(), and threadCounter_.
Referenced by createID().
unsigned int orxonox::TclThreadManager::createID | ( | unsigned int | threadID | ) | [static] |
Tcl::interpreter * orxonox::TclThreadManager::createNewTclInterpreter | ( | const std::string & | threadID | ) | [private] |
References COUT, Tcl::interpreter::def(), Tcl::interpreter::eval(), orxonox::TclBind::getInstance(), tcl_crossquery(), tcl_execute(), tcl_query(), tcl_running(), and Tcl::variadic().
Referenced by create().
void orxonox::TclThreadManager::debug | ( | const std::string & | error | ) |
void orxonox::TclThreadManager::destroy | ( | unsigned int | threadID | ) | [static] |
References orxonox::bundlesMutex_g, COUT, orxonox::TclInterpreterBundle::finished_, orxonox::TclInterpreterBundle::finishedMutex_, getInstance(), getInterpreterBundle(), orxonox::TclInterpreterBundle::interpreter_, interpreterBundles_, orxonox::TclInterpreterBundle::interpreterMutex_, orxonox::orxonoxEvalCondition_g, orxonox::TclInterpreterBundle::running_, and orxonox::TclInterpreterBundle::runningMutex_.
Referenced by ~TclThreadManager().
void orxonox::TclThreadManager::dump | ( | unsigned int | threadID | ) | [static] |
std::string orxonox::TclThreadManager::dumpList | ( | const std::list< unsigned int > & | list | ) | [private] |
void orxonox::TclThreadManager::error | ( | const std::string & | error | ) |
References forceCommandToFrontOfQueue(), orxonoxInterpreterBundle_, orxonox::TclInterpreterBundle::queue_, orxonox::TclInterpreterBundle::queueMutex_, orxonox::TCLTHREADMANAGER_MAX_QUEUE_LENGTH, and orxonox::threadID_g.
Referenced by evalQuery(), getInterpreterBundle(), pushCommandToQueue(), orxonox::tclThread(), and updateQueriersList().
std::string orxonox::TclThreadManager::evalQuery | ( | unsigned int | querierID, | |
unsigned int | threadID, | |||
const std::string & | command | |||
) | [private] |
References debug(), error(), Tcl::interpreter::eval(), getInterpreterBundle(), orxonox::TclInterpreterBundle::interpreter_, orxonox::TclInterpreterBundle::interpreterMutex_, orxonoxInterpreterBundle_, orxonox::TclInterpreterBundle::queriers_, orxonox::TclInterpreterBundle::queriersMutex_, orxonox::KeyCode::U, and updateQueriersList().
std::string orxonox::TclThreadManager::evalQuery | ( | unsigned int | querierID, | |
const std::string & | command | |||
) | [private] |
References error(), orxonox::CommandExecutor::execute(), getInterpreterBundle(), orxonox::CommandExecutor::getLastEvaluation(), orxonox::CommandEvaluation::getReturnvalue(), orxonox::MultiType::getString(), orxonox::TclInterpreterBundle::interpreterMutex_, orxonox::orxonoxEvalCondition_g, orxonoxInterpreterBundle_, orxonox::TclInterpreterBundle::queriers_, orxonox::TclInterpreterBundle::queriersMutex_, and updateQueriersList().
Referenced by query(), tcl_crossquery(), and tcl_query().
void orxonox::TclThreadManager::execute | ( | unsigned int | threadID, | |
const std::string & | command | |||
) | [static] |
References getInstance(), pushCommandToQueue(), and orxonox::stripEnclosingBraces().
Referenced by orxonox::IRC::initialize().
void orxonox::TclThreadManager::flush | ( | unsigned int | threadID | ) | [static] |
void orxonox::TclThreadManager::forceCommandToFrontOfQueue | ( | const std::string & | command | ) | [private] |
static TclThreadManager& orxonox::TclThreadManager::getInstance | ( | ) | [inline, static] |
TclInterpreterBundle * orxonox::TclThreadManager::getInterpreterBundle | ( | unsigned int | threadID | ) | [private] |
References orxonox::bundlesMutex_g, error(), and interpreterBundles_.
Referenced by destroy(), dump(), evalQuery(), flush(), getTclInterpreter(), popCommandFromQueue(), pushCommandToQueue(), queueIsEmpty(), and tcl_running().
Tcl::interpreter * orxonox::TclThreadManager::getTclInterpreter | ( | unsigned int | threadID | ) | [private] |
References getInterpreterBundle(), and orxonox::TclInterpreterBundle::interpreter_.
Referenced by orxonox::IRC::initialize().
std::list< unsigned int > orxonox::TclThreadManager::getThreadList | ( | ) | const |
References orxonox::bundlesMutex_g, and interpreterBundles_.
Referenced by orxonox::autocompletion::tclthreads().
std::string orxonox::TclThreadManager::popCommandFromQueue | ( | unsigned int | threadID | ) | [private] |
std::string orxonox::TclThreadManager::popCommandFromQueue | ( | ) | [private] |
References orxonox::fullQueueCondition_g, orxonoxInterpreterBundle_, orxonox::TclInterpreterBundle::queue_, and orxonox::TclInterpreterBundle::queueMutex_.
Referenced by update().
void orxonox::TclThreadManager::pushCommandToQueue | ( | unsigned int | threadID, | |
const std::string & | command | |||
) | [private] |
void orxonox::TclThreadManager::pushCommandToQueue | ( | const std::string & | command | ) | [private] |
std::string orxonox::TclThreadManager::query | ( | unsigned int | threadID, | |
const std::string & | command | |||
) | [static] |
References evalQuery(), getInstance(), orxonox::TclInterpreterBundle::id_, and orxonoxInterpreterBundle_.
bool orxonox::TclThreadManager::queueIsEmpty | ( | unsigned int | threadID | ) | [private] |
bool orxonox::TclThreadManager::queueIsEmpty | ( | ) | [private] |
References orxonoxInterpreterBundle_, orxonox::TclInterpreterBundle::queue_, and orxonox::TclInterpreterBundle::queueMutex_.
Referenced by update().
void orxonox::TclThreadManager::status | ( | ) | [static] |
std::string orxonox::TclThreadManager::tcl_crossquery | ( | int | querierID, | |
int | threadID, | |||
Tcl::object const & | args | |||
) | [static, private] |
References evalQuery(), Tcl::object::get(), getInstance(), and orxonox::stripEnclosingBraces().
Referenced by createNewTclInterpreter(), and orxonox::TclBind::createTclInterpreter().
void orxonox::TclThreadManager::tcl_execute | ( | Tcl::object const & | args | ) | [static, private] |
References Tcl::object::get(), getInstance(), pushCommandToQueue(), and orxonox::stripEnclosingBraces().
Referenced by createNewTclInterpreter().
std::string orxonox::TclThreadManager::tcl_query | ( | int | querierID, | |
Tcl::object const & | args | |||
) | [static, private] |
References evalQuery(), Tcl::object::get(), getInstance(), and orxonox::stripEnclosingBraces().
Referenced by createNewTclInterpreter().
bool orxonox::TclThreadManager::tcl_running | ( | int | threadID | ) | [static, private] |
References getInstance(), getInterpreterBundle(), orxonox::TclInterpreterBundle::running_, and orxonox::TclInterpreterBundle::runningMutex_.
Referenced by createNewTclInterpreter().
void orxonox::TclThreadManager::update | ( | const Clock & | time | ) |
References orxonox::bundlesMutex_g, orxonox::CommandExecutor::execute(), orxonox::Clock::getDeltaTime(), interpreterBundles_, orxonox::TclInterpreterBundle::interpreterMutex_, orxonox::orxonoxEvalCondition_g, orxonoxInterpreterBundle_, popCommandFromQueue(), queueIsEmpty(), orxonox::tclThread(), and orxonox::TCLTHREADMANAGER_MAX_CPU_USAGE.
Referenced by orxonox::Core::update().
bool orxonox::TclThreadManager::updateQueriersList | ( | TclInterpreterBundle * | querier, | |
TclInterpreterBundle * | target | |||
) | [private] |
References dumpList(), error(), orxonox::TclInterpreterBundle::id_, orxonox::TclInterpreterBundle::queriers_, and orxonox::TclInterpreterBundle::queriersMutex_.
Referenced by evalQuery().
friend class IRC [friend] |
friend class TclBind [friend] |
std::map<unsigned int, TclInterpreterBundle*> orxonox::TclThreadManager::interpreterBundles_ [private] |
Referenced by create(), destroy(), getInterpreterBundle(), getThreadList(), status(), update(), and ~TclThreadManager().
TclThreadManager * orxonox::TclThreadManager::singletonRef_s = 0 [static, private] |
Referenced by TclThreadManager(), and ~TclThreadManager().
unsigned int orxonox::TclThreadManager::threadCounter_ [private] |
Referenced by create(), createID(), and TclThreadManager().