mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
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:
parent
3b8bbb00ba
commit
abfe4e2a04
29 changed files with 1611 additions and 640 deletions
|
@ -246,11 +246,11 @@ typedef GSString *ivars;
|
|||
*/
|
||||
+ (BOOL) _scanDouble: (double*)value from: (NSString*)str
|
||||
{
|
||||
static pthread_mutex_t myLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static gs_mutex_t myLock = GS_MUTEX_INIT_STATIC;
|
||||
static NSScanner *doubleScanner = nil;
|
||||
BOOL ok = NO;
|
||||
|
||||
pthread_mutex_lock(&myLock);
|
||||
GS_MUTEX_LOCK(myLock);
|
||||
if (nil == doubleScanner)
|
||||
{
|
||||
doubleScanner = [[self alloc] initWithString: _empty];
|
||||
|
@ -258,7 +258,7 @@ typedef GSString *ivars;
|
|||
[doubleScanner _setString: str];
|
||||
ok = [doubleScanner scanDouble: value];
|
||||
[doubleScanner _setString: _empty]; // Release scanned string
|
||||
pthread_mutex_unlock(&myLock);
|
||||
GS_MUTEX_UNLOCK(myLock);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue