Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3313 was 3313, checked in by rgrieder, 15 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
Line 
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
32#include "CorePrereqs.h"
33
34#include <cassert>
35#include <list>
36#include <map>
37#include <string>
38#include "core/OrxonoxClass.h"
39
40namespace orxonox
41{
42    // Internal struct
43    struct TclInterpreterBundle;
44
45    class _CoreExport TclThreadManager : public OrxonoxClass
46    {
47        friend class IRC;
48        friend class TclBind;
49
50        public:
51            TclThreadManager(Tcl::interpreter* interpreter);
52            ~TclThreadManager();
53
54            static TclThreadManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
55
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);
64
65            void error(const std::string& error);
66            void debug(const std::string& error);
67
68            void update(const Clock& time);
69
70            std::list<unsigned int> getThreadList() const;
71
72        private:
73            TclThreadManager(const TclThreadManager& other);
74
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);
79
80            Tcl::interpreter* createNewTclInterpreter(const std::string& threadID);
81            Tcl::interpreter* getTclInterpreter(unsigned int threadID);
82            TclInterpreterBundle* getInterpreterBundle(unsigned int threadID);
83            std::string dumpList(const std::list<unsigned int>& list);
84
85            void pushCommandToQueue(const std::string& command);
86            void forceCommandToFrontOfQueue(const std::string& command);
87            std::string popCommandFromQueue();
88            bool queueIsEmpty();
89
90            void pushCommandToQueue(unsigned int threadID, const std::string& command);
91            std::string popCommandFromQueue(unsigned int threadID);
92            bool queueIsEmpty(unsigned int threadID);
93
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;
104    };
105
106    _CoreExport void tclThread(TclInterpreterBundle* interpreterBundle, std::string command);
107}
108
109#endif /* _TclThreadManager_H__ */
Note: See TracBrowser for help on using the repository browser.