Commit | Line | Data |
---|---|---|
47ba8780 AB |
1 | |
2 | #include "EXTERN.h" | |
3 | #include "perl.h" | |
4 | #include "XSUB.h" | |
5 | #include <stdio.h> | |
6 | #include <stdlib.h> | |
7 | ||
8 | #ifdef WIN32 | |
9 | #include <windows.h> | |
10 | #include <win32thread.h> | |
11 | #else | |
12 | #include <pthread.h> | |
13 | #include <thread.h> | |
14 | #endif | |
15 | ||
16 | typedef struct { | |
17 | PerlInterpreter *interp; /* The threads interpreter */ | |
18 | I32 tid; /* Our thread */ | |
19 | perl_mutex mutex; /* our mutex */ | |
20 | I32 count; /* how many threads have a reference to us */ | |
21 | signed char detached; /* are we detached ? */ | |
22 | SV* init_function; | |
23 | SV* params; | |
24 | #ifdef WIN32 | |
25 | DWORD thr; | |
26 | HANDLE handle; | |
27 | #else | |
28 | pthread_t thr; | |
29 | #endif | |
30 | } ithread; | |
31 | ||
32 | ||
33 | ||
34 | static perl_mutex create_mutex; /* protects the creation of threads ??? */ | |
35 | ||
36 | ||
37 | ||
38 | I32 tid_counter = 1; | |
39 | shared_sv* threads; | |
40 | ||
41 | ||
42 | ||
43 | ||
44 | ||
45 | ||
46 | /* internal functions */ | |
47 | #ifdef WIN32 | |
48 | THREAD_RET_TYPE thread_run(LPVOID arg); | |
49 | #else | |
50 | void thread_run(ithread* thread); | |
51 | #endif | |
52 | void thread_destruct(ithread* thread); | |
53 | ||
54 | /* Perl mapped functions to iThread:: */ | |
55 | SV* thread_create(char* class, SV* function_to_call, SV* params); | |
56 | I32 thread_tid (SV* obj); | |
57 | void thread_join(SV* obj); | |
58 | void thread_detach(SV* obj); | |
59 | SV* thread_self (char* class); | |
60 | ||
61 | ||
62 | ||
63 | ||
64 | ||
65 | ||
66 | ||
67 | ||
68 |