source: golgotha/src/i4/threads/threads.hh @ 608

Last change on this file since 608 was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.1 KB
Line 
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
12Example ussage of threads :
13
14void test(void *arg)
15{
16.. do something..
17}
18
19my_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
31typedef void (*i4_thread_func_type)(void *context);
32
33i4_bool i4_threads_supported();
34
35// this will start the thread right away, regardless of how many threads are running
36void i4_add_thread(i4_thread_func_type fun, w32 stack_size=50*1024, void *context=0);
37
38void i4_thread_yield();
39void i4_wait_threads();  // waits for all threads to terminate (don't call from a thread!)
40int  i4_get_thread_id();
41int  i4_get_main_thread_id();
42
43
44void i4_suspend_other_threads();  // stops all of threads from running
45void i4_resume_other_threads();   // resumes execution of other threads
46
47int i4_get_first_thread_id();
48i4_bool i4_get_next_thread_id(int last_id, int &id);
49void i4_get_thread_stack(int thread_id, void *&base, void *&top);
50
51
52enum i4_thread_priority_type { I4_THREAD_PRIORITY_HIGH,
53                               I4_THREAD_PRIORITY_NORMAL,
54                               I4_THREAD_PRIORITY_LOW };
55       
56void i4_set_thread_priority(int thread_id, i4_thread_priority_type priority);
57
58
59class i4_critical_section_class
60{
61  w32 data[6];  // to store operating system depandant data, enlarge if needed
62public:
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
70class i4_signal_object
71{
72  w32 data[1]; // to store operating system depandant data, enlarge if needed
73public:
74  i4_signal_object(char *name);
75  void wait_signal();
76  void signal();
77  ~i4_signal_object();
78};
79
80
81#endif
Note: See TracBrowser for help on using the repository browser.