Revision: 28419
http://sourceforge.net/p/bibdesk/svn/28419
Author: hofman
Date: 2023-11-04 17:07:33 +0000 (Sat, 04 Nov 2023)
Log Message:
-----------
use varying type for atomic variables
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVOperation.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVMappedDataProvider.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
2023-11-04 16:30:13 UTC (rev 28418)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVConcreteOperationQueue.m
2023-11-04 17:07:33 UTC (rev 28419)
@@ -71,7 +71,7 @@
{
int32_t maxConcurrentOperations = atomic_load(&_activeCPUs) * 10;
int32_t minConcurrentOperations = 2;
- return MAX((maxConcurrentOperations - (atomic_load(&_activeQueueCount - 1)
* minConcurrentOperations)), minConcurrentOperations);
+ return MAX((maxConcurrentOperations - ((atomic_load(&_activeQueueCount) -
1) * minConcurrentOperations)), minConcurrentOperations);
}
+ (void)_updateKernelInfo:(id)unused
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVOperation.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVOperation.m 2023-11-04
16:30:13 UTC (rev 28418)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVOperation.m 2023-11-04
17:07:33 UTC (rev 28419)
@@ -42,11 +42,11 @@
#import <stdatomic.h>
struct FVOpFlags {
- _Atomic(int32_t) _cancelled;
- _Atomic(int32_t) _priority;
- _Atomic(int32_t) _executing;
- _Atomic(int32_t) _finished;
- _Atomic(int32_t) _concurrent;
+ _Atomic(BOOL) _cancelled;
+ _Atomic(FVOperationQueuePriority) _priority;
+ _Atomic(BOOL) _executing;
+ _Atomic(BOOL) _finished;
+ _Atomic(BOOL) _concurrent;
};
@implementation FVOperation
@@ -97,19 +97,19 @@
- (void)cancel {
// allow multiple calls to -cancel
- atomic_fetch_add(&(_flags->_cancelled), 1);
+ atomic_store(&(_flags->_cancelled), YES);
};
- (BOOL)isCancelled {
- return 0 != atomic_load(&(_flags->_cancelled));
+ return atomic_load(&(_flags->_cancelled));
};
- (BOOL)isExecuting {
- return 1 == atomic_load(&(_flags->_executing));
+ return atomic_load(&(_flags->_executing));
};
- (BOOL)isFinished {
- return 1 == atomic_load(&(_flags->_finished));
+ return atomic_load(&(_flags->_finished));
};
- (void)main { [self doesNotRecognizeSelector:_cmd]; }
@@ -125,7 +125,7 @@
};
- (BOOL)isConcurrent {
- return 1 == atomic_load(&(_flags->_concurrent));
+ return atomic_load(&(_flags->_concurrent));
}
- (void)setConcurrent:(BOOL)flag {
@@ -134,8 +134,7 @@
if ([self isExecuting] || [self isFinished])
[NSException raise:NSInternalInconsistencyException format:@"attempt
to modify a previously executed operation"];
- int32_t val = flag ? 1 : 0;
- atomic_store(&(_flags->_concurrent), val);
+ atomic_store(&(_flags->_concurrent), flag);
}
// semantics here as the same as for NSDate, if we consider the dates as
absolute time values
@@ -155,7 +154,7 @@
if ([self isExecuting] || [self isFinished])
[NSException raise:NSInternalInconsistencyException format:@"attempt
to start a previously executed operation"];
- atomic_fetch_add(&(_flags->_executing), 1);
+ atomic_store(&(_flags->_executing), YES);
if ([self isConcurrent])
[FVThread detachNewThreadSelector:@selector(main) toTarget:self
withObject:nil];
@@ -167,7 +166,7 @@
{
// Make sure the queue releases its reference to this operation. This
always happens if it's cancelled by the queue, but someone else could call
-cancel, in which case this might be left in the queue's activeOperations bag.
[[self queue] finishedOperation:self];
- atomic_fetch_add(&(_flags->_finished), 1);
+ atomic_store(&(_flags->_finished), YES);
}
@end
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m 2023-11-04
16:30:13 UTC (rev 28418)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVThread.m 2023-11-04
17:07:33 UTC (rev 28419)
@@ -88,10 +88,10 @@
#define THREAD_POOL_MAX 60
#define THREAD_POOL_MIN 0
-static NSMutableArray *_threadPool = nil;
-static pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
-static int32_t _threadPoolCapacity = THREAD_POOL_MAX;
-static _Atomic(int32_t) _threadCount = 0;
+static NSMutableArray *_threadPool = nil;
+static pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
+static NSInteger _threadPoolCapacity = THREAD_POOL_MAX;
+static _Atomic(NSInteger) _threadCount = 0;
#define DEBUG_REAPER 0
@@ -192,11 +192,7 @@
self = [super init];
if (self) {
- // for debugging
- static _Atomic(int32_t) threadIndex = 0;
- atomic_fetch_add(&threadIndex, 1);
-
- _lastPerformTime = CFAbsoluteTimeGetCurrent();
+ _lastPerformTime = CFAbsoluteTimeGetCurrent();
_flags = 0;
__FVBitSet(_flags, FVThreadSetup);
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVMappedDataProvider.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVMappedDataProvider.m
2023-11-04 16:30:13 UTC (rev 28418)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/_FVMappedDataProvider.m
2023-11-04 17:07:33 UTC (rev 28419)
@@ -124,8 +124,7 @@
mapInfo->mapregion = NULL;
}
else {
- off_t newSize = atomic_load(&_mappedDataSizeKB) +
(mapInfo->length) / 1024;
- atomic_store(&_mappedDataSizeKB, newSize);
+ atomic_fetch_add(&_mappedDataSizeKB, (mapInfo->length) / 1024);
}
pInfo->_provider = CGDataProviderCreateDirect(mapInfo,
mapInfo->length, &_FVMappedDataProviderDirectCallBacks);
}
@@ -170,8 +169,7 @@
FVMappedRegion *mapInfo = info;
NSZoneFree(mapInfo->zone, mapInfo->path);
if (mapInfo->mapregion) munmap(mapInfo->mapregion, mapInfo->length);
- off_t newSize = atomic_load(&_mappedDataSizeKB) - (mapInfo->length) / 1024;
- atomic_store(&_mappedDataSizeKB, newSize);
+ atomic_fetch_sub(&_mappedDataSizeKB, (mapInfo->length) / 1024);
NSZoneFree(mapInfo->zone, info);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit