Use native threading and locking APIs on Windows

Removes dependency on pthread library and uses fast Slim Reader/Writer (SRW) locks for NSLock/NSRecursiveLock/NSCondition/NSConditionLock as well as all internal locks. Adds GS_MUTEX_*() macros in GSPThread.h, that are being used for all internal locking instead of pthread APIs.

Also adds support for thread priorities on Windows, fixes method signature of +[NSThread setThreadPriority:] to match Apple platforms, and adds error handling in same method.
This commit is contained in:
Frederik Seiffert 2021-07-28 16:17:47 +02:00 committed by Frederik Seiffert
parent 3b8bbb00ba
commit abfe4e2a04
29 changed files with 1611 additions and 640 deletions

View file

@ -86,7 +86,7 @@ static Class GSPlaceholderArrayClass;
static GSPlaceholderArray *defaultPlaceholderArray;
static NSMapTable *placeholderMap;
static pthread_mutex_t placeholderLock = PTHREAD_MUTEX_INITIALIZER;
static gs_mutex_t placeholderLock = GS_MUTEX_INIT_STATIC;
/**
@ -167,7 +167,7 @@ static SEL rlSel;
* locate the correct placeholder in the (lock protected)
* table of placeholders.
*/
(void)pthread_mutex_lock(&placeholderLock);
GS_MUTEX_LOCK(placeholderLock);
obj = (id)NSMapGet(placeholderMap, (void*)z);
if (obj == nil)
{
@ -178,7 +178,7 @@ static SEL rlSel;
obj = (id)NSAllocateObject(GSPlaceholderArrayClass, 0, z);
NSMapInsert(placeholderMap, (void*)z, (void*)obj);
}
(void)pthread_mutex_unlock(&placeholderLock);
GS_MUTEX_UNLOCK(placeholderLock);
return obj;
}
}