diff options
author | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-10-24 13:50:59 +0000 |
---|---|---|
committer | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-10-24 13:50:59 +0000 |
commit | ea0efc06fdad2019ffceb86d079dd853e9d79cea (patch) | |
tree | 7fedea92fa5ecf04cfd8d38fc6a0d997d14ac2d6 /win32/win32thread.c | |
parent | 4f01c5a5705fca4c6743c9938e82ea378a5b35e8 (diff) | |
download | perl-ea0efc06fdad2019ffceb86d079dd853e9d79cea.tar.gz |
Improve internal threading API. Introduce win32/win32thread.[ch]
to use new API and patch win32 makefile stuff a little.
p4raw-id: //depot/perl@172
Diffstat (limited to 'win32/win32thread.c')
-rw-r--r-- | win32/win32thread.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/win32/win32thread.c b/win32/win32thread.c new file mode 100644 index 0000000000..e74d7e8933 --- /dev/null +++ b/win32/win32thread.c @@ -0,0 +1,30 @@ +#include "EXTERN.h" +#include "perl.h" +#include "win32/win32thread.h" + +void +init_thread_intern(struct thread *thr) +{ + DuplicateHandle(GetCurrentProcess(), + GetCurrentThread(), + GetCurrentProcess(), + &self, + 0, + FALSE, + DUPLICATE_SAME_ACCESS); + if ((thr_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) + croak("panic: TlsAlloc"); + if (TlsSetValue(thr_key, (LPVOID) thr) != TRUE) + croak("panic: TlsSetValue"); +} + +int +thread_create(struct thread *thr, THREAD_RET_TYPE (*fn)(void *)) +{ + DWORD junk; + + MUTEX_LOCK(&thr->mutex); + self = CreateThread(NULL, 0, fn, (void*)thr, 0, &junk); + MUTEX_UNLOCK(&thr->mutex); + return self ? 0 : -1; +} |