Standardize property attributes and refactor private properties. This change: * Explicitly adds `nonatomic` to properties where thread safety is not required, improving performance. * Adds `atomic` to class properties and other properties where thread safety is important. * Refactors private properties in `ITRTestTraceRecorder` to be instance variables. * Simplifies the `EDODeviceDetector` by removing a redundant `started` property and using the channel's existence. PiperOrigin-RevId: 949734296
diff --git a/Channel/Sources/EDOBlockingQueue.h b/Channel/Sources/EDOBlockingQueue.h index 6082385..151d013 100644 --- a/Channel/Sources/EDOBlockingQueue.h +++ b/Channel/Sources/EDOBlockingQueue.h
@@ -31,10 +31,10 @@ @interface EDOBlockingQueue<ObjectType> : NSObject /** Whether the queue has any objects. */ -@property(readonly, getter=isEmpty) BOOL empty; +@property(atomic, readonly, getter=isEmpty) BOOL empty; /** The number of objects in the queue. */ -@property(readonly) NSUInteger count; +@property(atomic, readonly) NSUInteger count; /** Appends the @c object to the end of the queue. *
diff --git a/Channel/Sources/EDOChannelMultiplexer.h b/Channel/Sources/EDOChannelMultiplexer.h index 6b44a1e..948d33a 100644 --- a/Channel/Sources/EDOChannelMultiplexer.h +++ b/Channel/Sources/EDOChannelMultiplexer.h
@@ -39,7 +39,7 @@ @property(readonly, nonatomic) EDOHostPort *port; /** The number of channels that are set up with the forwarder and ready to connect. */ -@property(readonly) NSUInteger numberOfChannels; +@property(readonly, nonatomic) NSUInteger numberOfChannels; /** * Starts the multiplexer on the given @c port.
diff --git a/Channel/Sources/EDOChannelPool.h b/Channel/Sources/EDOChannelPool.h index bb3cb9a..70fb00d 100644 --- a/Channel/Sources/EDOChannelPool.h +++ b/Channel/Sources/EDOChannelPool.h
@@ -32,13 +32,13 @@ @interface EDOChannelPool : NSObject /** The singleton of @c EDOChannelPool. */ -@property(class, readonly) EDOChannelPool *sharedChannelPool; +@property(atomic, class, readonly) EDOChannelPool *sharedChannelPool; /** * A port for clients to accept connection, and receive host name to register as service. This port * will lazily create a listen socket when accessed. */ -@property(readonly) UInt16 serviceConnectionPort; +@property(nonatomic, readonly) UInt16 serviceConnectionPort; /** * Fetches an already-connected channel from the pool, keyed by the host @c port.
diff --git a/Channel/Sources/EDOHostPort.h b/Channel/Sources/EDOHostPort.h index 64f6a76..fdee671 100644 --- a/Channel/Sources/EDOHostPort.h +++ b/Channel/Sources/EDOHostPort.h
@@ -31,7 +31,7 @@ * TODO(haowoo): This will be used to identify whether the host is on a real device or a machine * later, to replace deviceSerialNumber. */ -@property(readonly, class) NSString *deviceIdentifier; +@property(readonly, class, nonatomic) NSString *deviceIdentifier; /** The listen port number of the host. 0 if the host port is identified by name. */ @property(readonly, nonatomic) UInt16 port;
diff --git a/Device/Sources/EDODeviceConnector.h b/Device/Sources/EDODeviceConnector.h index 0bb44c0..600e80f 100644 --- a/Device/Sources/EDODeviceConnector.h +++ b/Device/Sources/EDODeviceConnector.h
@@ -40,9 +40,9 @@ @interface EDODeviceConnector : NSObject /** The serial numbers of connected devices. */ -@property(readonly) NSArray<NSString *> *connectedDevices; +@property(nonatomic, readonly) NSArray<NSString *> *connectedDevices; /** Shared device connector. */ -@property(readonly, class) EDODeviceConnector *sharedConnector; +@property(atomic, readonly, class) EDODeviceConnector *sharedConnector; - (instancetype)init NS_UNAVAILABLE;
diff --git a/Device/Sources/EDODeviceDetector.m b/Device/Sources/EDODeviceDetector.m index 8a58265..5277bc9 100644 --- a/Device/Sources/EDODeviceDetector.m +++ b/Device/Sources/EDODeviceDetector.m
@@ -25,8 +25,6 @@ * is called. */ @property(nonatomic) EDODeviceChannel *channel; -/** @c YES if the detector has already started to listen to broadcast. */ -@property(readonly) BOOL started; @end @@ -37,7 +35,7 @@ __block NSError *resultError; EDODeviceChannel *deviceChannel; @synchronized(self) { - if (!self.started) { + if (!self.channel) { deviceChannel = [EDODeviceChannel channelWithError:&resultError]; self.channel = deviceChannel; } else { @@ -93,10 +91,6 @@ } } -- (BOOL)started { - return self.channel != nil; -} - #pragma mark - Private - (void)edo_scheduleReadBroadcastPacketWithHandler:(EDOBroadcastHandler)handler {
diff --git a/Service/Sources/EDOHostNamingService.h b/Service/Sources/EDOHostNamingService.h index 3a23cb3..45ac787 100644 --- a/Service/Sources/EDOHostNamingService.h +++ b/Service/Sources/EDOHostNamingService.h
@@ -32,16 +32,16 @@ @interface EDOHostNamingService : NSObject /** The default port number 11237 which the naming service will be listening on. */ -@property(class, readonly) UInt16 namingServerPort; +@property(nonatomic, class, readonly) UInt16 namingServerPort; /** Shared singleton instance. */ -@property(class, readonly) EDOHostNamingService *sharedService; +@property(atomic, class, readonly) EDOHostNamingService *sharedService; /** * The port for service registration. Clients can connect to this port to register their * services by name. */ -@property(readonly) UInt16 serviceConnectionPort; +@property(nonatomic, readonly) UInt16 serviceConnectionPort; - (instancetype)init NS_UNAVAILABLE;
diff --git a/Service/Sources/EDORemoteException.h b/Service/Sources/EDORemoteException.h index 72c83ee..8c40284 100644 --- a/Service/Sources/EDORemoteException.h +++ b/Service/Sources/EDORemoteException.h
@@ -24,7 +24,7 @@ @interface EDORemoteException : NSException <NSSecureCoding> /** The merged call stack traces of both client process and host process. */ -@property(readonly, copy) NSArray<NSString *> *callStackSymbols; +@property(atomic, readonly, copy) NSArray<NSString *> *callStackSymbols; /** EDORemoteException cannot be initialized with default data members. */ - (instancetype)init NS_UNAVAILABLE;
diff --git a/Service/Sources/EDOServiceRequest.h b/Service/Sources/EDOServiceRequest.h index a7d9d72..e04cfec 100644 --- a/Service/Sources/EDOServiceRequest.h +++ b/Service/Sources/EDOServiceRequest.h
@@ -45,7 +45,7 @@ * The sub classes should override this and provide its own handler. The default implementation * returns an EDOErrorRequestNotHandled response. */ -@property(readonly, class) EDORequestHandler requestHandler; +@property(readonly, class, nonatomic) EDORequestHandler requestHandler; - (instancetype)initWithMessageID:(NSString *)messageID NS_UNAVAILABLE;