4 #ifdef USE_DECLSPEC_THREAD
5 __declspec(thread) struct perl_thread *Perl_current_thread = NULL;
9 Perl_setTHR(struct perl_thread *t)
11 #ifdef USE_DECLSPEC_THREAD
12 Perl_current_thread = t;
14 TlsSetValue(thr_key,t);
21 #ifdef USE_DECLSPEC_THREAD
22 return Perl_current_thread;
24 return (struct perl_thread *) TlsGetValue(thr_key);
29 Perl_alloc_thread_key(void)
32 static int key_allocated = 0;
34 if ((thr_key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
35 croak("panic: TlsAlloc");
42 Perl_set_thread_self(struct perl_thread *thr)
45 /* Set thr->self. GetCurrentThread() retrurns a pseudo handle, need
46 this to convert it into a handle another thread can use.
48 DuplicateHandle(GetCurrentProcess(),
54 DUPLICATE_SAME_ACCESS);
60 Perl_thread_create(struct perl_thread *thr, thread_func_t *fn)
64 MUTEX_LOCK(&thr->mutex);
65 DEBUG_L(PerlIO_printf(PerlIO_stderr(),
66 "%p: create OS thread\n", thr));
67 thr->self = CreateThread(NULL, 0, fn, (void*)thr, 0, &junk);
68 DEBUG_L(PerlIO_printf(PerlIO_stderr(),
69 "%p: OS thread = %p, id=%ld\n", thr, thr->self, junk));
70 MUTEX_UNLOCK(&thr->mutex);
71 return thr->self ? 0 : -1;