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