Skip to content

Commit edd9202

Browse files
Remove "run on work queue" bits from non-concrete controllers. (project-chip#36320)
* Remove "run on work queue" bits from non-concrete controllers. There is no "work queue" in the sense of the Matter queue involved unless we have a concrete controller. * syncRunOnWorkQueueWithReturnValue was unused on MTRDeviceController, so can just be removed. * syncRunOnWorkQueueWithBoolReturnValue was unused on MTRDeviceController, so can just be removed. * After that syncRunOnWorkQueue becomes unused and can be removed. * At this point chipWorkQueue is not used on the base class and can be moved into the subclasses as needed. * Apply suggestion from code review.
1 parent aff2e17 commit edd9202

File tree

3 files changed

+4
-40
lines changed

3 files changed

+4
-40
lines changed

src/darwin/Framework/CHIP/MTRDeviceController.mm

-34
Original file line numberDiff line numberDiff line change
@@ -542,40 +542,6 @@ - (void)asyncDispatchToMatterQueue:(dispatch_block_t)block errorHandler:(nullabl
542542
errorHandler([MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]);
543543
}
544544

545-
- (void)syncRunOnWorkQueue:(SyncWorkQueueBlock)block error:(NSError * __autoreleasing *)error
546-
{
547-
VerifyOrDie(!chip::DeviceLayer::PlatformMgrImpl().IsWorkQueueCurrentQueue());
548-
VerifyOrReturn([self checkIsRunning:error]);
549-
550-
dispatch_sync(_chipWorkQueue, ^{
551-
VerifyOrReturn([self checkIsRunning:error]);
552-
block();
553-
});
554-
}
555-
556-
- (id)syncRunOnWorkQueueWithReturnValue:(SyncWorkQueueBlockWithReturnValue)block error:(NSError * __autoreleasing *)error
557-
{
558-
__block id rv = nil;
559-
auto adapter = ^{
560-
rv = block();
561-
};
562-
563-
[self syncRunOnWorkQueue:adapter error:error];
564-
565-
return rv;
566-
}
567-
568-
- (BOOL)syncRunOnWorkQueueWithBoolReturnValue:(SyncWorkQueueBlockWithBoolReturnValue)block error:(NSError * __autoreleasing *)error
569-
{
570-
__block BOOL success = NO;
571-
auto adapter = ^{
572-
success = block();
573-
};
574-
[self syncRunOnWorkQueue:adapter error:error];
575-
576-
return success;
577-
}
578-
579545
- (chip::FabricIndex)fabricIndex
580546
{
581547
return _storedFabricIndex;

src/darwin/Framework/CHIP/MTRDeviceController_Internal.h

-3
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
6868
@property (readonly, assign) os_unfair_lock_t deviceMapLock;
6969

7070
@property (readwrite, nonatomic) NSUUID * uniqueIdentifier;
71-
72-
// queue used to serialize all work performed by the MTRDeviceController
7371
// (moved here so subclasses can initialize differently)
74-
@property (readwrite, retain) dispatch_queue_t chipWorkQueue;
7572

7673
- (instancetype)initForSubclasses:(BOOL)startSuspended;
7774

src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ @interface MTRDeviceController_XPC ()
3737
@property (nonnull, atomic, readwrite, retain) MTRXPCDeviceControllerParameters * xpcParameters;
3838
@property (atomic, readwrite, assign) NSTimeInterval xpcRetryTimeInterval;
3939
@property (atomic, readwrite, assign) BOOL xpcConnectedOrConnecting;
40+
@property (nonatomic, readonly, retain) dispatch_queue_t workQueue;
4041

4142
@end
4243

@@ -194,7 +195,7 @@ - (void)_startXPCConnectionRetry
194195
self.xpcRetryTimeInterval = 0.5;
195196
mtr_weakify(self);
196197

197-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (self.xpcRetryTimeInterval * NSEC_PER_SEC)), self.chipWorkQueue, ^{
198+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (self.xpcRetryTimeInterval * NSEC_PER_SEC)), self.workQueue, ^{
198199
mtr_strongify(self);
199200
[self _xpcConnectionRetry];
200201
});
@@ -214,7 +215,7 @@ - (void)_xpcConnectionRetry
214215
self.xpcRetryTimeInterval = MIN(60.0, self.xpcRetryTimeInterval);
215216
mtr_weakify(self);
216217

217-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.xpcRetryTimeInterval * NSEC_PER_SEC)), self.chipWorkQueue, ^{
218+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.xpcRetryTimeInterval * NSEC_PER_SEC)), self.workQueue, ^{
218219
mtr_strongify(self);
219220
[self _xpcConnectionRetry];
220221
});
@@ -302,7 +303,7 @@ - (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParamete
302303

303304
self.uniqueIdentifier = UUID;
304305
self.xpcParameters = xpcParameters;
305-
self.chipWorkQueue = dispatch_queue_create("MTRDeviceController_XPC_queue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
306+
_workQueue = dispatch_queue_create("MTRDeviceController_XPC_queue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
306307

307308
if (![self _setupXPCConnection]) {
308309
return nil;

0 commit comments

Comments
 (0)