Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/TclThreadManager.h @ 3313

Last change on this file since 3313 was 3313, checked in by rgrieder, 16 years ago

Reverted TclThreadManager commits to make a tag (there's possibly still an unresolved issue with the TclThreadManager under linux when terminating the game (mutex assert)).

  • Property svn:eol-style set to native
File size: 3.9 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
29#ifndef _TclThreadManager_H__
30#define _TclThreadManager_H__
31
[1535]32#include "CorePrereqs.h"
33
[3304]34#include <cassert>
[3313]35#include <list>
[1505]36#include <map>
[3196]37#include <string>
[3313]38#include "core/OrxonoxClass.h"
[1505]39
40namespace orxonox
41{
[3313]42    // Internal struct
43    struct TclInterpreterBundle;
44
[1535]45    class _CoreExport TclThreadManager : public OrxonoxClass
[1505]46    {
[3313]47        friend class IRC;
[1747]48        friend class TclBind;
49
[1505]50        public:
[1792]51            TclThreadManager(Tcl::interpreter* interpreter);
[3313]52            ~TclThreadManager();
[1505]53
[3313]54            static TclThreadManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
[1792]55
[3313]56            static unsigned int create();
57            static unsigned int createID(unsigned int threadID);
58            static void destroy(unsigned int threadID);
59            static void execute(unsigned int threadID, const std::string& command);
60            static std::string query(unsigned int threadID, const std::string& command);
61            static void status();
62            static void dump(unsigned int threadID);
63            static void flush(unsigned int threadID);
[1505]64
[1747]65            void error(const std::string& error);
66            void debug(const std::string& error);
67
[2896]68            void update(const Clock& time);
[1747]69
70            std::list<unsigned int> getThreadList() const;
71
72        private:
[3313]73            TclThreadManager(const TclThreadManager& other);
[1747]74
[3313]75            static void tcl_execute(Tcl::object const &args);
76            static std::string tcl_query(int querierID, Tcl::object const &args);
77            static std::string tcl_crossquery(int querierID, int threadID, Tcl::object const &args);
78            static bool tcl_running(int threadID);
[1505]79
[3313]80            Tcl::interpreter* createNewTclInterpreter(const std::string& threadID);
81            Tcl::interpreter* getTclInterpreter(unsigned int threadID);
82            TclInterpreterBundle* getInterpreterBundle(unsigned int threadID);
[1505]83            std::string dumpList(const std::list<unsigned int>& list);
84
[3313]85            void pushCommandToQueue(const std::string& command);
86            void forceCommandToFrontOfQueue(const std::string& command);
87            std::string popCommandFromQueue();
88            bool queueIsEmpty();
[1505]89
[3313]90            void pushCommandToQueue(unsigned int threadID, const std::string& command);
91            std::string popCommandFromQueue(unsigned int threadID);
92            bool queueIsEmpty(unsigned int threadID);
[1505]93
[3313]94            bool updateQueriersList(TclInterpreterBundle* querier, TclInterpreterBundle* target);
95
96            std::string evalQuery(unsigned int querierID, const std::string& command);
97            std::string evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command);
98
99            unsigned int threadCounter_;
100            TclInterpreterBundle* orxonoxInterpreterBundle_;
101            std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_;
102
103            static TclThreadManager* singletonRef_s;
[1505]104    };
105
[3313]106    _CoreExport void tclThread(TclInterpreterBundle* interpreterBundle, std::string command);
[1505]107}
108
109#endif /* _TclThreadManager_H__ */
Note: See TracBrowser for help on using the repository browser.