#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/command/TclThreadManager.h>
|
static unsigned int | create () |
| Creates a new Tcl-interpreter. More...
|
|
static Tcl::interpreter * | createWithId (unsigned int id) |
| Creates a new Tcl-interpreter with a given id. More...
|
|
static void | debug (const std::string &error) |
| A helper function to print debug information in a thread safe manner. More...
|
|
static void | destroy (unsigned int id) |
| Stops and destroys a given Tcl-interpreter. More...
|
|
static void | error (const std::string &error) |
| A helper function to print errors in a thread safe manner. More...
|
|
static void | execute (unsigned int target_id, const std::string &command) |
| Sends a command to the queue of a given Tcl-interpreter. More...
|
|
static std::string | query (unsigned int target_id, const std::string &command) |
| Sends a query to a given Tcl-interpreter and waits for the result. More...
|
|
static void | source (const std::string &file) |
| Creates a non-interactive Tcl-interpreter which executes a file. More...
|
|
static bool | exists () |
| Tells whether the singleton has been created. More...
|
|
static TclThreadManager & | getInstance () |
| Returns a reference to the singleton instance. More...
|
|
|
void | _execute (unsigned int target_id, const std::string &command) |
| Sends a command to the queue of a given Tcl-interpreter. More...
|
|
std::string | _query (unsigned int source_id, unsigned int target_id, const std::string &command, bool bUseCommandExecutor=false) |
| This function performs a query to any Tcl interpreter. More...
|
|
std::string | dumpList (const std::list< unsigned int > &list) |
| Returns a string containing all elements of a unsigned-integer-list separated by spaces. More...
|
|
TclInterpreterBundle * | getInterpreterBundle (unsigned int id) |
| Returns the interpreter bundle with the given id. More...
|
|
|
static std::string | eval (TclInterpreterBundle *bundle, const std::string &command, const std::string &action) |
| Evaluates a Tcl command without throwing exceptions (which may rise problems on certain machines). More...
|
|
static void | initialize (TclInterpreterBundle *bundle) |
|
static void | tcl_crossexecute (int target_id, const Tcl::object &args) |
| This function can be called from Tcl to send a command to the queue of any interpreter. More...
|
|
static std::string | tcl_crossquery (int source_id, int target_id, const Tcl::object &args) |
| This function can be called from Tcl to send a query to another thread. More...
|
|
static void | tcl_execute (const Tcl::object &args) |
| This function can be called from Tcl to execute a console command. More...
|
|
static std::string | tcl_query (int source_id, const Tcl::object &args) |
| This function can be called from Tcl to send a query to the main thread. More...
|
|
static bool | tcl_running (int id) |
| This function can be called from Tcl to ask if the thread is still suposed to be running. More...
|
|
orxonox::TclThreadManager::TclThreadManager |
( |
Tcl::interpreter * |
interpreter | ) |
|
Constructor.
- Parameters
-
interpreter | A pointer to the standard Tcl-interpreter (see TclBind) |
orxonox::TclThreadManager::~TclThreadManager |
( |
| ) |
|
|
virtual |
void orxonox::TclThreadManager::_execute |
( |
unsigned int |
target_id, |
|
|
const std::string & |
command |
|
) |
| |
|
private |
Sends a command to the queue of a given Tcl-interpreter.
- Parameters
-
target_id | The id of the target interpreter |
command | The command to be sent |
std::string orxonox::TclThreadManager::_query |
( |
unsigned int |
source_id, |
|
|
unsigned int |
target_id, |
|
|
const std::string & |
command, |
|
|
bool |
bUseCommandExecutor = false |
|
) |
| |
|
private |
This function performs a query to any Tcl interpreter.
- Parameters
-
source_id | The id of the calling thread |
target_id | The id of the target thread |
command | The command to send as a query |
bUseCommandExecutor | Only used if the target_id is 0 (which references the main interpreter). In this case it means if the command should be passed to the CommandExecutor (true) or to the main Tcl interpreter (false). This is true when called by tcl_query() and false when called by tcl_crossquery(). |
unsigned int orxonox::TclThreadManager::create |
( |
| ) |
|
|
static |
Creates a new Tcl-interpreter.
Tcl::interpreter * orxonox::TclThreadManager::createWithId |
( |
unsigned int |
id | ) |
|
|
static |
Creates a new Tcl-interpreter with a given id.
Use with caution - if the id collides with an already existing interpreter, this call will fail. This will also be a problem, if the auto-numbered interpreters (by using create()) reach an id which was previously used in this function. Use high numbers to be safe.
void orxonox::TclThreadManager::debug |
( |
const std::string & |
error | ) |
|
|
static |
A helper function to print debug information in a thread safe manner.
void orxonox::TclThreadManager::destroy |
( |
unsigned int |
id | ) |
|
|
static |
Stops and destroys a given Tcl-interpreter.
std::string orxonox::TclThreadManager::dumpList |
( |
const std::list< unsigned int > & |
list | ) |
|
|
private |
Returns a string containing all elements of a unsigned-integer-list separated by spaces.
void orxonox::TclThreadManager::error |
( |
const std::string & |
error | ) |
|
|
static |
A helper function to print errors in a thread safe manner.
std::string orxonox::TclThreadManager::eval |
( |
TclInterpreterBundle * |
bundle, |
|
|
const std::string & |
command, |
|
|
const std::string & |
action |
|
) |
| |
|
staticprivate |
Evaluates a Tcl command without throwing exceptions (which may rise problems on certain machines).
- Returns
- The Tcl return value
Errors are reported through the error function.
void orxonox::TclThreadManager::execute |
( |
unsigned int |
target_id, |
|
|
const std::string & |
command |
|
) |
| |
|
static |
Sends a command to the queue of a given Tcl-interpreter.
- Parameters
-
target_id | The id of the target interpreter |
command | The command to be sent |
Returns the interpreter bundle with the given id.
- Parameters
-
id | The id of the interpreter |
- Returns
- The interpreter or 0 if the id doesn't exist
std::list< unsigned int > orxonox::TclThreadManager::getThreadList |
( |
| ) |
const |
Returns a list with the numbers of all existing Tcl-interpreters.
This function is used by the auto completion function.
void orxonox::TclThreadManager::preUpdate |
( |
const Clock & |
time | ) |
|
The "main loop" of the TclThreadManager.
Creates new threads if needed and handles queries and queued commands for the main interpreter.
std::string orxonox::TclThreadManager::query |
( |
unsigned int |
target_id, |
|
|
const std::string & |
command |
|
) |
| |
|
static |
Sends a query to a given Tcl-interpreter and waits for the result.
- Parameters
-
target_id | The id of the target interpreter |
command | The command to be sent |
- Returns
- The result of the command
void orxonox::TclThreadManager::source |
( |
const std::string & |
file | ) |
|
|
static |
Creates a non-interactive Tcl-interpreter which executes a file.
void orxonox::TclThreadManager::tcl_crossexecute |
( |
int |
target_id, |
|
|
const Tcl::object & |
args |
|
) |
| |
|
staticprivate |
This function can be called from Tcl to send a command to the queue of any interpreter.
- Parameters
-
target_id | The id of the target thread |
args | Contains the content of the command |
std::string orxonox::TclThreadManager::tcl_crossquery |
( |
int |
source_id, |
|
|
int |
target_id, |
|
|
const Tcl::object & |
args |
|
) |
| |
|
staticprivate |
This function can be called from Tcl to send a query to another thread.
- Parameters
-
source_id | The id of the calling thread |
target_id | The id of the target thread |
args | Contains the content of the query |
void orxonox::TclThreadManager::tcl_execute |
( |
const Tcl::object & |
args | ) |
|
|
staticprivate |
This function can be called from Tcl to execute a console command.
Commands which shall be executed are put into a queue and processed as soon as the main thread feels ready to do so. The queue may also be full which results in a temporary suspension of the calling thread until the queue gets ready again.
std::string orxonox::TclThreadManager::tcl_query |
( |
int |
source_id, |
|
|
const Tcl::object & |
args |
|
) |
| |
|
staticprivate |
This function can be called from Tcl to send a query to the main thread.
- Parameters
-
source_id | The id of the calling thread |
args | Contains the content of the query |
A query waits for the result of the command. This means, the calling thread will be blocked until the main thread answers the query. In return, the main thread sends the result of the console command back to Tcl.
bool orxonox::TclThreadManager::tcl_running |
( |
int |
id | ) |
|
|
staticprivate |
This function can be called from Tcl to ask if the thread is still suposed to be running.
- Parameters
-
id | The id of the thread in question |
The main function of a non-interactive source thread.
Executes the file.
- Parameters
-
file | The name of the file that should be executed by the non-interactive interpreter. |
_CoreExport int Tcl_OrxonoxAppInit |
( |
Tcl_Interp * |
interp | ) |
|
|
friend |
A tcl-init hook to inject the non-interactive Tcl-interpreter into the TclThreadManager.
The main function of the thread.
Executes a Tcl command.
- Parameters
-
bundle | The interpreter bundle containing all necessary variables |
command | the Command to execute |
A map containing all Tcl-interpreters.
boost::shared_mutex* orxonox::TclThreadManager::interpreterBundlesMutex_ |
|
private |
boost::mutex* orxonox::TclThreadManager::mainInterpreterMutex_ |
|
private |
A mutex to synchronize queries to the main interpreter.
TclThreadList<std::string>* orxonox::TclThreadManager::messageQueue_ |
|
private |
A queue to pass messages from Tcl-threads to the main thread.
unsigned int orxonox::TclThreadManager::numInterpreterBundles_ |
|
private |
Number of created Tcl-interpreters (only used for auto-numbered interpreters, not affected by createWithId)
The documentation for this class was generated from the following files: