source: trunk/essentials/dev-lang/perl/win32/win32thread.h@ 3188

Last change on this file since 3188 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 6.4 KB
Line 
1#ifndef _WIN32THREAD_H
2#define _WIN32THREAD_H
3
4#include "win32.h"
5
6typedef struct win32_cond { LONG waiters; HANDLE sem; } perl_cond;
7typedef DWORD perl_key;
8typedef HANDLE perl_os_thread;
9
10#ifndef DONT_USE_CRITICAL_SECTION
11
12/* Critical Sections used instead of mutexes: lightweight,
13 * but can't be communicated to child processes, and can't get
14 * HANDLE to it for use elsewhere.
15 */
16typedef CRITICAL_SECTION perl_mutex;
17#define MUTEX_INIT(m) InitializeCriticalSection(m)
18#define MUTEX_LOCK(m) EnterCriticalSection(m)
19#define MUTEX_UNLOCK(m) LeaveCriticalSection(m)
20#define MUTEX_DESTROY(m) DeleteCriticalSection(m)
21
22#else
23
24typedef HANDLE perl_mutex;
25# define MUTEX_INIT(m) \
26 STMT_START { \
27 if ((*(m) = CreateMutex(NULL,FALSE,NULL)) == NULL) \
28 Perl_croak_nocontext("panic: MUTEX_INIT"); \
29 } STMT_END
30
31# define MUTEX_LOCK(m) \
32 STMT_START { \
33 if (WaitForSingleObject(*(m),INFINITE) == WAIT_FAILED) \
34 Perl_croak_nocontext("panic: MUTEX_LOCK"); \
35 } STMT_END