1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 |
|
---|
10 | /*
|
---|
11 |
|
---|
12 | Example ussage of threads :
|
---|
13 |
|
---|
14 | void test(void *arg)
|
---|
15 | {
|
---|
16 | .. do something..
|
---|
17 | }
|
---|
18 |
|
---|
19 | my_main()
|
---|
20 | {
|
---|
21 | i4_add_thread(test,10*1024);
|
---|
22 | }
|
---|
23 |
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef I4_THREADS_HH
|
---|
27 | #define I4_THREADS_HH
|
---|
28 |
|
---|
29 | #include "arch.hh"
|
---|
30 |
|
---|
31 | typedef void (*i4_thread_func_type)(void *context);
|
---|
32 |
|
---|
33 | i4_bool i4_threads_supported();
|
---|
34 |
|
---|
35 | // this will start the thread right away, regardless of how many threads are running
|
---|
36 | void i4_add_thread(i4_thread_func_type fun, w32 stack_size=50*1024, void *context=0);
|
---|
37 |
|
---|
38 | void i4_thread_yield();
|
---|
39 | void i4_wait_threads(); // waits for all threads to terminate (don't call from a thread!)
|
---|
40 | int i4_get_thread_id();
|
---|
41 | int i4_get_main_thread_id();
|
---|
42 |
|
---|
43 |
|
---|
44 | void i4_suspend_other_threads(); // stops all of threads from running
|
---|
45 | void i4_resume_other_threads(); // resumes execution of other threads
|
---|
46 |
|
---|
47 | int i4_get_first_thread_id();
|
---|
48 | i4_bool i4_get_next_thread_id(int last_id, int &id);
|
---|
49 | void i4_get_thread_stack(int thread_id, void *&base, void *&top);
|
---|
50 |
|
---|
51 |
|
---|
52 | enum i4_thread_priority_type { I4_THREAD_PRIORITY_HIGH,
|
---|
53 | I4_THREAD_PRIORITY_NORMAL,
|
---|
54 | I4_THREAD_PRIORITY_LOW };
|
---|
55 |
|
---|
56 | void i4_set_thread_priority(int thread_id, i4_thread_priority_type priority);
|
---|
57 |
|
---|
58 |
|
---|
59 | class i4_critical_section_class
|
---|
60 | {
|
---|
61 | w32 data[6]; // to store operating system depandant data, enlarge if needed
|
---|
62 | public:
|
---|
63 | i4_critical_section_class();
|
---|
64 | void I4_FAST_CALL lock();
|
---|
65 | void I4_FAST_CALL unlock();
|
---|
66 | ~i4_critical_section_class();
|
---|
67 | };
|
---|
68 |
|
---|
69 |
|
---|
70 | class i4_signal_object
|
---|
71 | {
|
---|
72 | w32 data[1]; // to store operating system depandant data, enlarge if needed
|
---|
73 | public:
|
---|
74 | i4_signal_object(char *name);
|
---|
75 | void wait_signal();
|
---|
76 | void signal();
|
---|
77 | ~i4_signal_object();
|
---|
78 | };
|
---|
79 |
|
---|
80 |
|
---|
81 | #endif
|
---|