diff --git a/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.m b/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.m index d16f372c5340b8..d78057edf078cf 100644 --- a/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.m +++ b/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.m @@ -65,14 +65,12 @@ void CHIPSetNextAvailableDeviceID(uint64_t id) CHIPDeviceController * InitializeCHIP(void) { - static dispatch_queue_t callbackQueue; static CHIPToolPersistentStorageDelegate * storage = nil; static dispatch_once_t onceToken; CHIPDeviceController * controller = [CHIPDeviceController sharedController]; dispatch_once(&onceToken, ^{ storage = [[CHIPToolPersistentStorageDelegate alloc] init]; - callbackQueue = dispatch_queue_create("com.chip.persistentstorage.callback", DISPATCH_QUEUE_SERIAL); - [controller startup:storage queue:callbackQueue]; + [controller startup:storage]; }); return controller; diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.h b/src/darwin/Framework/CHIP/CHIPDeviceController.h index fbddde6f7e6aa8..11b304f2d08996 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.h +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.h @@ -89,10 +89,8 @@ NS_ASSUME_NONNULL_BEGIN * check if the stack needs to be started up. * * @param[in] storageDelegate The delegate for persistent storage - * - * @param[in] queue The queue on which the storage callbacks will be delivered */ -- (BOOL)startup:(_Nullable id)storageDelegate queue:(_Nullable dispatch_queue_t)queue; +- (BOOL)startup:(_Nullable id)storageDelegate; /** * Shutdown the CHIP Stack. Repeated calls to shutdown without calls to startup in between are NO-OPs. diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.mm b/src/darwin/Framework/CHIP/CHIPDeviceController.mm index 35c9cad791fe0f..745dedc3bda7f9 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.mm +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.mm @@ -122,7 +122,7 @@ - (BOOL)shutdown return YES; } -- (BOOL)startup:(_Nullable id)storageDelegate queue:(_Nullable dispatch_queue_t)queue +- (BOOL)startup:(_Nullable id)storageDelegate { __block BOOL commissionerInitialized = NO; dispatch_sync(_chipWorkQueue, ^{ @@ -133,7 +133,7 @@ - (BOOL)startup:(_Nullable id)storageDelegate que CHIP_ERROR errorCode = CHIP_ERROR_INCORRECT_STATE; - _persistentStorageDelegateBridge->setFrameworkDelegate(storageDelegate, queue); + _persistentStorageDelegateBridge->setFrameworkDelegate(storageDelegate); // initialize NodeID if needed [self _getControllerNodeId]; diff --git a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h index fc5be8b0a94670..e0780b08016f6e 100644 --- a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h +++ b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h @@ -28,7 +28,7 @@ class CHIPPersistentStorageDelegateBridge : public chip::PersistentStorageDelega CHIPPersistentStorageDelegateBridge(); ~CHIPPersistentStorageDelegateBridge(); - void setFrameworkDelegate(_Nullable id delegate, _Nullable dispatch_queue_t queue); + void setFrameworkDelegate(_Nullable id delegate); CHIP_ERROR SyncGetKeyValue(const char * key, void * buffer, uint16_t & size) override; diff --git a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm index 01ea04fd044046..e7a605b16e7521 100644 --- a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm @@ -60,16 +60,13 @@ CHIPPersistentStorageDelegateBridge::~CHIPPersistentStorageDelegateBridge(void) {} -void CHIPPersistentStorageDelegateBridge::setFrameworkDelegate( - _Nullable id delegate, _Nullable dispatch_queue_t queue) +void CHIPPersistentStorageDelegateBridge::setFrameworkDelegate(_Nullable id delegate) { dispatch_async(mWorkQueue, ^{ - if (delegate && queue) { + if (delegate) { mDelegate = delegate; - mQueue = queue; } else { mDelegate = nil; - mQueue = nil; } }); } @@ -125,10 +122,8 @@ NSLog(@"PersistentStorageDelegate Set Key %@", keyString); id strongDelegate = mDelegate; - if (strongDelegate && mQueue) { - dispatch_sync(mQueue, ^{ - [strongDelegate CHIPSetKeyValue:keyString value:valueString]; - }); + if (strongDelegate) { + [strongDelegate CHIPSetKeyValue:keyString value:valueString]; } else { [mDefaultPersistentStorage setObject:valueString forKey:keyString]; } @@ -148,10 +143,8 @@ NSLog(@"PersistentStorageDelegate Delete Key: %@", keyString); id strongDelegate = mDelegate; - if (strongDelegate && mQueue) { - dispatch_sync(mQueue, ^{ - [strongDelegate CHIPDeleteKeyValue:keyString]; - }); + if (strongDelegate) { + [strongDelegate CHIPDeleteKeyValue:keyString]; } else { [mDefaultPersistentStorage removeObjectForKey:keyString]; } diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 690f6ddc6d68ac..3c2d0dd9feeb95 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -95,7 +95,7 @@ - (void)testInitStack [controller setListenPort:kLocalPort]; [controller setPairingDelegate:pairing queue:callbackQueue]; - BOOL started = [controller startup:nil queue:nil]; + BOOL started = [controller startup:nil]; XCTAssertTrue(started); NSError * error;