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:
1.6 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 | #include "threads/threads.hh"
|
---|
10 | #include "error/error.hh"
|
---|
11 |
|
---|
12 | #include <windows.h>
|
---|
13 | #include <process.h>
|
---|
14 |
|
---|
15 | static w32 i4_thread_count=0;
|
---|
16 | static i4_critical_section_class i4_thread_lock;
|
---|
17 | int i4_main_thread_id;
|
---|
18 |
|
---|
19 | void i4_wait_threads() // waits for all threads to terminate (don't call from a thread!)
|
---|
20 | {
|
---|
21 | while (i4_thread_count!=0)
|
---|
22 | i4_thread_yield();
|
---|
23 | }
|
---|
24 |
|
---|
25 | static i4_critical_section_class i4_thread_start_lock;
|
---|
26 | static i4_thread_func_type i4_thread_to_start;
|
---|
27 |
|
---|
28 | void i4_thread_starter(void *arg)
|
---|
29 | {
|
---|
30 | i4_thread_func_type start=i4_thread_to_start;
|
---|
31 | i4_thread_start_lock.unlock();
|
---|
32 | start(arg);
|
---|
33 |
|
---|
34 | i4_thread_lock.lock();
|
---|
35 | i4_thread_count--;
|
---|
36 | i4_thread_lock.unlock();
|
---|
37 |
|
---|
38 | _endthread();
|
---|
39 | }
|
---|
40 |
|
---|
41 | void i4_add_thread(i4_thread_func_type fun, w32 stack_size, void *arg_list)
|
---|
42 |
|
---|
43 | {
|
---|
44 | i4_thread_start_lock.lock();
|
---|
45 | i4_thread_to_start=fun;
|
---|
46 |
|
---|
47 | i4_thread_lock.lock();
|
---|
48 | i4_thread_count++;
|
---|
49 | i4_thread_lock.unlock();
|
---|
50 |
|
---|
51 | _beginthread(i4_thread_starter, stack_size, arg_list);
|
---|
52 | }
|
---|
53 |
|
---|
54 | void i4_thread_yield()
|
---|
55 | {
|
---|
56 | Sleep(0);
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | int i4_get_thread_id()
|
---|
61 | {
|
---|
62 | return GetCurrentThreadId();
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.