Skip to content

Commit

Permalink
Create dispatch queues in the Darwin framework more consistently. (#2…
Browse files Browse the repository at this point in the history
…4005)

* Create dispatch queues in the Darwin framework more consistently.

* Use a common prefix for all the queue labels ("org.csa-iot.matter.framework").
* Use DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL for all the queues.
* Use a common suffix ("workqueue") for all work queues.

* Address review comment
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Sep 14, 2023
1 parent 46551f6 commit 2214853
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ - (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceControlle
_nodeID = [nodeID copy];
_fabricIndex = controller.fabricIndex;
_deviceController = controller;
_queue = dispatch_queue_create("com.apple.matter.framework.device.workqueue", DISPATCH_QUEUE_SERIAL);
_queue
= dispatch_queue_create("org.csa-iot.matter.framework.device.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
_readCache = [NSMutableDictionary dictionary];
_expectedValueCache = [NSMutableDictionary dictionary];
_asyncCallbackWorkQueue = [[MTRAsyncCallbackWorkQueue alloc] initWithContext:self queue:_queue];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class MTRDeviceAttestationDelegateBridge : public chip::Credentials::DeviceAttes
: mResult(chip::Credentials::AttestationVerificationResult::kSuccess)
, mDeviceController(deviceController)
, mDeviceAttestationDelegate(deviceAttestationDelegate)
, mQueue(dispatch_queue_create("com.csa.matter.framework.device_attestation.workqueue", DISPATCH_QUEUE_SERIAL))
, mQueue(dispatch_queue_create(
"org.csa-iot.matter.framework.device_attestation.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL))
, mExpiryTimeoutSecs(expiryTimeoutSecs)
, mShouldWaitAfterDeviceAttestation(shouldWaitAfterDeviceAttestation)
{
Expand Down
3 changes: 2 additions & 1 deletion src/darwin/Framework/CHIP/MTRDeviceControllerOverXPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
static void SetupXPCQueue(void)
{
dispatch_once(&workQueueInitOnceToken, ^{
globalWorkQueue = dispatch_queue_create("com.apple.matter.framework.xpc.workqueue", DISPATCH_QUEUE_SERIAL);
globalWorkQueue
= dispatch_queue_create("org.csa-iot.matter.framework.xpc.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ void ResetState()

MTROTAProviderDelegateBridge::MTROTAProviderDelegateBridge(id<MTROTAProviderDelegate> delegate)
: mDelegate(delegate)
, mDelegateNotificationQueue(dispatch_queue_create("com.csa.matter.framework.otaprovider.workqueue", DISPATCH_QUEUE_SERIAL))
, mDelegateNotificationQueue(
dispatch_queue_create("org.csa-iot.matter.framework.otaprovider.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL))
{
gOtaSender.SetDelegate(delegate, mDelegateNotificationQueue);
Clusters::OTAProvider::SetDelegate(kOtaProviderEndpoint, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

MTRPersistentStorageDelegateBridge::MTRPersistentStorageDelegateBridge(id<MTRStorage> delegate)
: mDelegate(delegate)
, mWorkQueue(dispatch_queue_create("com.csa.matter.framework.storage.workqueue", DISPATCH_QUEUE_SERIAL))
, mWorkQueue(
dispatch_queue_create("org.csa-iot.matter.framework.storage.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL))
{
}

Expand Down
3 changes: 2 additions & 1 deletion src/platform/Darwin/BleConnectionDelegateImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ - (id)init
self = [super init];
if (self) {
self.shortServiceUUID = [UUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
_workQueue = dispatch_queue_create("com.chip.ble.work_queue", DISPATCH_QUEUE_SERIAL);
_workQueue
= dispatch_queue_create("org.csa-iot.matter.framework.ble.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
_chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue();
_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _workQueue);
_centralManager = [CBCentralManager alloc];
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Darwin/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <dispatch/dispatch.h>
#include <platform/internal/GenericPlatformManagerImpl.h>

static constexpr const char * const CHIP_CONTROLLER_QUEUE = "com.csa.matter.framework.controller.workqueue";
static constexpr const char * const CHIP_CONTROLLER_QUEUE = "org.csa-iot.matter.framework.controller.workqueue";

namespace chip {
namespace DeviceLayer {
Expand All @@ -47,7 +47,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
{
if (mWorkQueue == nullptr)
{
mWorkQueue = dispatch_queue_create(CHIP_CONTROLLER_QUEUE, DISPATCH_QUEUE_SERIAL);
mWorkQueue = dispatch_queue_create(CHIP_CONTROLLER_QUEUE, DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
dispatch_suspend(mWorkQueue);
mIsWorkQueueSuspended = true;
}
Expand Down

0 comments on commit 2214853

Please sign in to comment.