Revision: 27866
http://sourceforge.net/p/bibdesk/svn/27866
Author: hofman
Date: 2022-09-07 14:40:33 +0000 (Wed, 07 Sep 2022)
Log Message:
-----------
async object flags as direct ivar, not allocated
Modified Paths:
--------------
trunk/bibdesk/BDSKAsyncObject.h
trunk/bibdesk/BDSKAsyncObject.m
trunk/bibdesk/BDSKSharingServer.m
Modified: trunk/bibdesk/BDSKAsyncObject.h
===================================================================
--- trunk/bibdesk/BDSKAsyncObject.h 2022-09-07 09:36:19 UTC (rev 27865)
+++ trunk/bibdesk/BDSKAsyncObject.h 2022-09-07 14:40:33 UTC (rev 27866)
@@ -38,12 +38,18 @@
#import <Cocoa/Cocoa.h>
+typedef struct _BDSKAsyncObjectFlags {
+ volatile int32_t shouldKeepRunning;
+#ifdef DEBUG
+ volatile int32_t didStart;
+#endif
+} BDSKAsyncObjectFlags;
@interface BDSKAsyncObject : NSObject {
@private
NSThread *localThread; // mainly for debugging
BOOL stopRunning; // set to signal to stop running
the run loop for the local server thread
- struct BDSKAsyncObjectFlags *aoFlags; // state variables
+ BDSKAsyncObjectFlags aoFlags; // state variables
}
/*
Modified: trunk/bibdesk/BDSKAsyncObject.m
===================================================================
--- trunk/bibdesk/BDSKAsyncObject.m 2022-09-07 09:36:19 UTC (rev 27865)
+++ trunk/bibdesk/BDSKAsyncObject.m 2022-09-07 14:40:33 UTC (rev 27866)
@@ -40,13 +40,6 @@
#import <objc/runtime.h>
#import <libkern/OSAtomic.h>
-struct BDSKAsyncObjectFlags {
- volatile int32_t shouldKeepRunning;
-#ifdef DEBUG
- volatile int32_t didStart;
-#endif
-};
-
@interface BDSKAsyncObject (Private)
- (void)runLocalThread;
- (void)stopRunning;
@@ -59,7 +52,7 @@
#ifdef DEBUG
- (void)checkStartup:(NSTimer *)ignored
{
- if (0 == aoFlags->didStart)
+ if (0 == aoFlags.didStart)
NSLog(@"*** Warning *** %@ has not been started after 1 second", self);
}
#endif
@@ -69,10 +62,9 @@
self = [super init];
if (self) {
// set up flags
- aoFlags = NSZoneCalloc(NSDefaultMallocZone(), 1, sizeof(struct
BDSKAsyncObjectFlags));
- aoFlags->shouldKeepRunning = 1;
+ aoFlags.shouldKeepRunning = 1;
#ifdef DEBUG
- aoFlags->didStart = 0;
+ aoFlags.didStart = 0;
// check for absentminded developers; there's no actual requirement
that start be called immediately
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self
selector:@selector(checkStartup:) userInfo:nil repeats:NO];
@@ -83,18 +75,12 @@
return self;
}
-- (void)dealloc
-{
- BDSKZONEDESTROY(aoFlags);
- [super dealloc];
-}
-
#pragma mark Main Thread
- (void)start;
{
#ifdef DEBUG
- aoFlags->didStart = 1;
+ aoFlags.didStart = 1;
#endif
// run a background thread
localThread = [[NSThread alloc] initWithTarget:self
selector:@selector(runLocalThread) object:nil];
@@ -167,7 +153,7 @@
{
BDSKASSERT([NSThread isMainThread]);
// set the stop flag, so any long process (possibly with loops) knows it
can return
- OSAtomicCompareAndSwap32Barrier(1, 0, &aoFlags->shouldKeepRunning);
+ OSAtomicCompareAndSwap32Barrier(1, 0, &aoFlags.shouldKeepRunning);
// this is mainly to tickle the runloop on the local thread so it will
finish
[self performSelectorOnLocalThread:@selector(stopRunning) withObject:nil
waitUntilDone:NO];
BDSKDESTROY(localThread);
@@ -177,7 +163,7 @@
- (BOOL)shouldKeepRunning {
OSMemoryBarrier();
- return aoFlags->shouldKeepRunning == 1;
+ return aoFlags.shouldKeepRunning == 1;
}
@end
Modified: trunk/bibdesk/BDSKSharingServer.m
===================================================================
--- trunk/bibdesk/BDSKSharingServer.m 2022-09-07 09:36:19 UTC (rev 27865)
+++ trunk/bibdesk/BDSKSharingServer.m 2022-09-07 14:40:33 UTC (rev 27866)
@@ -690,9 +690,8 @@
[registeredClients removeAllObjects];
[self setNumberOfConnections:0];
- NSPort *port = [[NSSocketPortNameServer sharedInstance]
portForName:sharingName];
[[NSSocketPortNameServer sharedInstance] removePortForName:sharingName];
- [port invalidate];
+ [[connection receivePort] invalidate];
[connection setDelegate:nil];
[connection setRootObject:nil];
[connection invalidate];
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