Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/doc/src/libraries/core/command/TclThreadManager.h @ 7361

Last change on this file since 7361 was 7361, checked in by landauf, 14 years ago

added documentation

  • Property svn:eol-style set to native
File size: 4.5 KB
RevLine 
[1505]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
[7361]29/**
30    @file
31    @ingroup Command Tcl
32    @brief Declaration of TclThreadManager, used to create multithreaded Tcl interpreters.
33*/
34
[1505]35#ifndef _TclThreadManager_H__
36#define _TclThreadManager_H__
37
[7203]38#include "core/CorePrereqs.h"
[1535]39
[3304]40#include <cassert>
[3370]41#include <list>
[1505]42#include <map>
[3196]43#include <string>
[1505]44
[3370]45#include "util/Singleton.h"
[3318]46
[3370]47struct Tcl_Interp;
48
[1505]49namespace orxonox
50{
[7281]51    class _CoreExport TclThreadManager : public Singleton<TclThreadManager>
[1505]52    {
[3370]53        friend class Singleton<TclThreadManager>;
[1747]54        friend class TclBind;
[6417]55        friend _CoreExport void tclThread(TclInterpreterBundle* bundle, const std::string& command);
56        friend _CoreExport void sourceThread(const std::string& file);
[3370]57        friend _CoreExport int Tcl_OrxonoxAppInit(Tcl_Interp* interp);
[1747]58
[1505]59        public:
[1792]60            TclThreadManager(Tcl::interpreter* interpreter);
[3318]61            virtual ~TclThreadManager();
[1505]62
[3318]63            static unsigned int      create();
64            static Tcl::interpreter* createWithId(unsigned int id);
65            static void              destroy(unsigned int id);
66            static void              execute(unsigned int target_id, const std::string& command);
67            static std::string       query(unsigned int target_id, const std::string& command);
[3370]68            static void              source(const std::string& file);
[1505]69
[3370]70            static void error(const std::string& error);
71            static void debug(const std::string& error);
[1747]72
[6417]73            void preUpdate(const Clock& time);
[1747]74
75            std::list<unsigned int> getThreadList() const;
76
77        private:
[3318]78            static void tcl_execute(const Tcl::object& args);
79            static void tcl_crossexecute(int target_id, const Tcl::object& args);
80            static std::string tcl_query(int source_id, const Tcl::object& args);
81            static std::string tcl_crossquery(int source_id, int target_id, const Tcl::object& args);
82            static bool tcl_running(int id);
[1747]83
[3318]84            void _execute(unsigned int target_id, const std::string& command);
85            std::string _query(unsigned int source_id, unsigned int target_id, const std::string& command, bool bUseCommandExecutor = false);
[1505]86
[3318]87            TclInterpreterBundle* getInterpreterBundle(unsigned int id);
[1505]88            std::string dumpList(const std::list<unsigned int>& list);
89
[3370]90            static void initialize(TclInterpreterBundle* bundle);
91            static std::string eval(TclInterpreterBundle* bundle, const std::string& command, const std::string& action);
[1505]92
[3318]93            static TclThreadManager* singletonPtr_s;                            ///< Singleton pointer
[1505]94
[3318]95            unsigned int numInterpreterBundles_;                                ///< Number of created Tcl-interpreters (only used for auto-numbered interpreters, not affected by @ref createWithId)
96            std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_;  ///< A map containing all Tcl-interpreters
97            boost::shared_mutex* interpreterBundlesMutex_;                      ///< A mutex used to synchronize threads when accessing @ref interpreterBundles_
98            TclThreadList<std::string>* messageQueue_;                          ///< A queue to pass messages from Tcl-threads to the main thread
99            boost::mutex* mainInterpreterMutex_;                                ///< A mutex to synchronize queries to the main interpreter
[1505]100    };
101
[6417]102    _CoreExport void tclThread(TclInterpreterBundle* bundle, const std::string& command);
103    _CoreExport void sourceThread(const std::string& file);
[3370]104    _CoreExport int Tcl_OrxonoxAppInit(Tcl_Interp* interp);
[1505]105}
106
107#endif /* _TclThreadManager_H__ */
Note: See TracBrowser for help on using the repository browser.