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 | |
e6e315b9 | 48 | THREAD_RET_TYPE Perl_thread_run(LPVOID arg); |
47ba8780 | 49 | #else |
5b414d21 | 50 | void Perl_thread_run(void * arg); |
47ba8780 | 51 | #endif |
e6e315b9 | 52 | void Perl_thread_destruct(ithread* thread); |
47ba8780 AB |
53 | |
54 | /* Perl mapped functions to iThread:: */ | |
e6e315b9 AB |
55 | SV* Perl_thread_create(char* class, SV* function_to_call, SV* params); |
56 | I32 Perl_thread_tid (SV* obj); | |
57 | void Perl_thread_join(SV* obj); | |
58 | void Perl_thread_detach(SV* obj); | |
59 | SV* Perl_thread_self (char* class); | |
47ba8780 AB |
60 | |
61 | ||
62 | ||
63 | ||
64 | ||
65 | ||
66 | ||
67 | ||
68 |