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 ILLUSIONS_THREAD_H
23#define ILLUSIONS_THREAD_H
24
25#include "common/list.h"
26
27namespace Illusions {
28
29class IllusionsEngine;
30
31enum ThreadType {
32 kTTScriptThread = 1,
33 kTTTimerThread = 2,
34 kTTTalkThread = 3,
35 kTTAbortableThread = 4,
36 kTTSpecialThread = 5,
37 kTTCauseThread = 6
38};
39
40enum ThreadStatus {
41 kTSTerminate = 1,
42 kTSYield = 2,
43 kTSSuspend = 3,
44 kTSRun = 4
45};
46
47class Thread {
48public:
49 Thread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags);
50 virtual ~Thread();
51 virtual int onUpdate();
52 virtual void onSuspend();
53 virtual void onNotify();
54 virtual void onPause();
55 virtual void onUnpause();
56 virtual void onResume();
57 virtual void onTerminated();
58 virtual void onKill();
59 virtual uint32 sendMessage(int msgNum, uint32 msgValue);
60 void pause();
61 void unpause();
62 void resume();
63 void suspend();
64 void notify();
65 int update();
66 void terminate();
67public:
68 IllusionsEngine *_vm;
69 //field_0 dw
70 int _pauseCtr;
71 bool _terminated;
72 //field_6 dw
73 uint _type;
74 uint32 _threadId;
75 uint32 _callingThreadId;
76 uint32 _sceneId;
77 uint _notifyFlags;
78};
79
81public:
83 void startThread(Thread *thread);
84 void updateThreads();
85 Thread *findThread(uint32 threadId);
86 void suspendId(uint32 threadId);
87 void notifyId(uint32 threadId);
88 void notifyTimerThreads(uint32 callingThreadId);
89 void suspendTimerThreads(uint32 callingThreadId);
90 void terminateThreads(uint32 threadId);
91 void terminateActiveThreads(uint32 threadId);
92 void terminateThreadsBySceneId(uint32 sceneId, uint32 threadId);
93 void suspendThreadsBySceneId(uint32 sceneId, uint32 threadId);
94 void notifyThreads(uint32 threadId);
95 void notifyThreadsBySceneId(uint32 sceneId, uint32 threadId);
96 void pauseThreads(uint32 threadId);
97 void unpauseThreads(uint32 threadId);
98 void suspendThreads(uint32 threadId);
99 void resumeThreads(uint32 threadId);
100 void endTalkThreads();
101 void endTalkThreadsNoNotify();
102 void terminateThreadChain(uint32 threadId);
103 void killThread(uint32 threadId);
104 void setThreadSceneId(uint32 threadId, uint32 sceneId);
105 uint32 getThreadSceneId(uint32 threadId);
106 bool isActiveThread(int msgNum);
107 ~ThreadList();
108protected:
110 typedef List::iterator Iterator;
111 IllusionsEngine *_vm;
112 List _threads;
113};
114
115} // End of namespace Illusions
116
117#endif // ILLUSIONS_THREAD_H
Definition: illusions.h:92
Definition: thread.h:47
Definition: thread.h:80
Definition: list_intern.h:54