ScummVM API documentation
thread.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TWP_THREAD_H
23 #define TWP_THREAD_H
24 
25 #include "common/array.h"
26 #include "common/str.h"
27 #include "twp/squirrel/squirrel.h"
28 
29 namespace Twp {
30 
31 class Thread {
32 public:
33  Thread(const Common::String &name, bool global, HSQOBJECT threadObj, HSQOBJECT envObj, HSQOBJECT closureObj, const Common::Array<HSQOBJECT> args);
34  ~Thread();
35 
36  int getId() const { return _id; }
37  bool isGlobal() const { return _global; }
38  HSQUIRRELVM getThread() const { return _threadObj._unVal.pThread; }
39  const Common::String &getName() const { return _name; }
40 
41  bool call();
42  bool update(float elapsed);
43 
44  void pause();
45  void unpause();
46  void stop();
47 
48  bool isSuspended() const;
49  bool isDead() const;
50 
51  void suspend();
52  void resume();
53 
54 public:
55  float _waitTime = 0.f;
56  int _numFrames = 0;
57  bool _pauseable = false;
58  uint32 _lastUpdateTime = 0;
59 
60 private:
61  int _id = 0;
62  Common::String _name;
63  bool _stopRequest = false;
64  bool _paused = false;
65  bool _global = false;
66  HSQOBJECT _threadObj, _envObj, _closureObj;
68 };
69 
70 } // namespace Twp
71 
72 #endif
Definition: sqvm.h:33
Definition: str.h:59
Definition: array.h:52
Definition: squirrel.h:153
Definition: thread.h:31
Definition: achievements_tables.h:27