This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Adds the thread 0.05 module. It is now moved to the core from CPAN.
[perl5.git] / ext / threads / threads.h
CommitLineData
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
16typedef 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
34static perl_mutex create_mutex; /* protects the creation of threads ??? */
35
36
37
38I32 tid_counter = 1;
39shared_sv* threads;
40
41
42
43
44
45
46/* internal functions */
47#ifdef WIN32
48THREAD_RET_TYPE thread_run(LPVOID arg);
49#else
50void thread_run(ithread* thread);
51#endif
52void thread_destruct(ithread* thread);
53
54/* Perl mapped functions to iThread:: */
55SV* thread_create(char* class, SV* function_to_call, SV* params);
56I32 thread_tid (SV* obj);
57void thread_join(SV* obj);
58void thread_detach(SV* obj);
59SV* thread_self (char* class);
60
61
62
63
64
65
66
67
68