diff --git a/src/xpdev/threadwrap.h b/src/xpdev/threadwrap.h index 28b18382512013e295bf135a444535bca945a489..6b1776e0ff1934091357b250d219358797146f15 100644 --- a/src/xpdev/threadwrap.h +++ b/src/xpdev/threadwrap.h @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2002 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -77,6 +77,9 @@ extern "C" { #define pthread_mutex_lock(pmtx) EnterCriticalSection(pmtx) #define pthread_mutex_unlock(pmtx) LeaveCriticalSection(pmtx) #define pthread_mutex_destroy(pmtx) DeleteCriticalSection(pmtx) + /* TryEnterCriticalSection only available on NT4+ :-( */ + #define pthread_mutex_trylock(pmtx) (TryEnterCriticalSection(pmtx)?0:EBUSY) + #else /* Implemented as Win32 Mutexes (much slower) */ typedef HANDLE pthread_mutex_t; #define PTHREAD_MUTEX_INITIALIZER CreateMutex(NULL,FALSE,NULL) @@ -84,6 +87,7 @@ extern "C" { #define pthread_mutex_lock(pmtx) WaitForSingleObject(*(pmtx),INFINITE) #define pthread_mutex_unlock(pmtx) ReleaseMutex(*(pmtx)) #define pthread_mutex_destroy(pmtx) CloseHandle(*(pmtx)) + #define pthread_mutex_trylock(pmtx) (WaitForSingleObject(*(pmtx),0)==WAIT_OBJECT_0?0:EBUSY) #endif #elif defined(__OS2__) /* These have *not* been tested! */