Skip to content

Commit f2dd444

Browse files
authored
[darwin-framework-tool] Use DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL instead of DISPATCH_QUEUE_SERIAL (project-chip#35876)
1 parent 6022500 commit f2dd444

File tree

9 files changed

+4053
-4052
lines changed

9 files changed

+4053
-4052
lines changed

examples/darwin-framework-tool/commands/bdx/DownloadLogCommand.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
auto * device = [MTRDevice deviceWithNodeID:@(mNodeId) controller:commissioner];
3232

3333
auto logType = static_cast<MTRDiagnosticLogType>(mLogType);
34-
auto queue = dispatch_queue_create("com.chip.bdx.downloader", DISPATCH_QUEUE_SERIAL);
34+
auto queue = dispatch_queue_create("com.chip.bdx.downloader", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
3535

3636
bool shouldWaitForDownload = !mIsAsyncCommand.ValueOr(false);
3737
mIsAsyncCommand.ClearValue();

examples/darwin-framework-tool/commands/clusters/ClusterCommandBridge.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ClusterCommand : public ModelCommand {
7171
{
7272
uint16_t repeatCount = mRepeatCount.ValueOr(1);
7373
uint16_t __block responsesNeeded = repeatCount;
74-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
74+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
7575

7676
while (repeatCount--) {
7777
[device invokeCommandWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]

examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ReadAttribute : public ModelCommand {
5252

5353
CHIP_ERROR SendCommand(MTRBaseDevice * _Nonnull device, chip::EndpointId endpointId) override
5454
{
55-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
55+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
5656
MTRReadParams * params = [[MTRReadParams alloc] init];
5757
if (mFabricFiltered.HasValue()) {
5858
params.filterByFabric = mFabricFiltered.Value();
@@ -124,7 +124,7 @@ class SubscribeAttribute : public ModelCommand {
124124

125125
CHIP_ERROR SendCommand(MTRBaseDevice * _Nonnull device, chip::EndpointId endpointId) override
126126
{
127-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
127+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
128128

129129
MTRSubscribeParams * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
130130
if (mFabricFiltered.HasValue()) {
@@ -214,7 +214,7 @@ class SubscribeEvent : public ModelCommand {
214214

215215
CHIP_ERROR SendCommand(MTRBaseDevice * _Nonnull device, chip::EndpointId endpointId) override
216216
{
217-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
217+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
218218

219219
MTRSubscribeParams * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
220220
if (mEventNumber.HasValue()) {
@@ -324,7 +324,7 @@ class ReadEvent : public ModelCommand {
324324

325325
CHIP_ERROR SendCommand(MTRBaseDevice * _Nonnull device, chip::EndpointId endpointId) override
326326
{
327-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
327+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
328328
MTRReadParams * params = [[MTRReadParams alloc] init];
329329
if (mFabricFiltered.HasValue()) {
330330
params.filterByFabric = mFabricFiltered.Value();

examples/darwin-framework-tool/commands/clusters/WriteAttributeCommandBridge.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class WriteAttribute : public ModelCommand {
7272
CHIP_ERROR SendCommand(MTRBaseDevice * _Nonnull device, chip::EndpointId endpointId, chip::ClusterId clusterId,
7373
chip::AttributeId attributeId, id _Nonnull value)
7474
{
75-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
75+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
76+
7677
[device
7778
writeAttributeWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
7879
clusterID:[NSNumber numberWithUnsignedInteger:clusterId]

examples/darwin-framework-tool/commands/discover/DiscoverCommissionablesCommand.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "DiscoverCommissionablesCommand.h"
1919

2020
NSMutableArray * gDiscoveredDevices = [[NSMutableArray alloc] init];
21-
auto gDispatchQueue = dispatch_queue_create("com.chip.discover", DISPATCH_QUEUE_SERIAL);
21+
auto gDispatchQueue = dispatch_queue_create("com.chip.discover", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
2222

2323
@interface DeviceScannerDelegate : NSObject <MTRCommissionableBrowserDelegate>
2424
- (void)controller:(MTRDeviceController *)controller didFindCommissionableDevice:(MTRCommissionableBrowserResult *)device;

examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
CHIP_ERROR OpenCommissioningWindowCommand::RunCommand()
2525
{
26-
mWorkQueue = dispatch_queue_create("com.chip.open_commissioning_window", DISPATCH_QUEUE_SERIAL);
26+
mWorkQueue = dispatch_queue_create("com.chip.open_commissioning_window", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
2727
auto * controller = CurrentCommissioner();
2828
auto * device = [MTRDevice deviceWithNodeID:mNodeId deviceController:controller];
2929

examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ - (void)deviceAttestationCompletedForController:(MTRDeviceController *)controlle
8383

8484
MTRDeviceController * commissioner = CurrentCommissioner();
8585
[deviceControllerDelegate setCommissioner:commissioner];
86-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.pairing", DISPATCH_QUEUE_SERIAL);
86+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.pairing", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
8787
[commissioner setDeviceControllerDelegate:deviceControllerDelegate queue:callbackQueue];
8888
}
8989

@@ -156,7 +156,7 @@ - (void)deviceAttestationCompletedForController:(MTRDeviceController *)controlle
156156

157157
void PairingCommandBridge::Unpair()
158158
{
159-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip-tool.command", DISPATCH_QUEUE_SERIAL);
159+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip-tool.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
160160
auto * device = BaseDeviceWithNodeId(mNodeId);
161161

162162
ChipLogProgress(chipTool, "Attempting to unpair device %llu", mNodeId);

examples/darwin-framework-tool/templates/commands.zapt

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public:
6565

6666
ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, commandId, endpointId);
6767

68-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
68+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
6969
__auto_type * cluster = [[MTRBaseCluster{{asUpperCamelCase parent.name preserveAcronyms=true}} alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue];
7070
__auto_type * params = [[MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params alloc] init];
7171
params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil;
@@ -159,7 +159,7 @@ public:
159159

160160
ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId);
161161

162-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
162+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
163163
__auto_type * cluster = [[MTRBase{{>cluster}} alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue];
164164
{{#if_is_fabric_scoped_struct type}}
165165
__auto_type * params = [[MTRReadParams alloc] init];
@@ -217,7 +217,7 @@ public:
217217
constexpr chip::AttributeId attributeId = chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::Id;
218218

219219
ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") WriteAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId);
220-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
220+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
221221
__auto_type * cluster = [[MTRBase{{>cluster}} alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue];
222222
__auto_type * params = [[MTRWriteParams alloc] init];
223223
params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil;
@@ -290,7 +290,7 @@ public:
290290
constexpr chip::CommandId attributeId = chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::Id;
291291

292292
ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId);
293-
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
293+
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
294294
__auto_type * cluster = [[MTRBase{{>cluster}} alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue];
295295
__auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
296296
if (mKeepSubscriptions.HasValue()) {

0 commit comments

Comments
 (0)