@@ -2890,38 +2890,40 @@ - (void)doTestSubscriptionPoolWithSize:(NSInteger)subscriptionPoolSize deviceOnb
2890
2890
};
2891
2891
}
2892
2892
2893
- // We have one fake device, which we use an invalid node ID for, that we use
2894
- // to test what happens if a device is deallocated while its subscription
2895
- // work item is queued.
2896
- //
2897
- // Schedule a job in the controller's pool that will not complete until the
2898
- // fake device is deallocated.
2899
- __auto_type * fakeDeviceDeletedExpectation = [self expectationWithDescription:@"Fake device deleted"];
2900
- MTRAsyncWorkItem * blockingWorkItem = [[MTRAsyncWorkItem alloc] initWithQueue:queue];
2901
- [blockingWorkItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {
2902
- [self waitForExpectations:@[ fakeDeviceDeletedExpectation ] timeout:kTimeoutInSeconds];
2903
- completion(MTRAsyncWorkComplete);
2904
- }];
2905
- [controller.concurrentSubscriptionPool enqueueWorkItem:blockingWorkItem description:@"Waiting for fake device deletion"];
2906
-
2907
- // Make sure the delegate for the fake device does not go away before the
2908
- // fake device does, so keep it out of the @autoreleasepool block.
2909
- MTRDeviceTestDelegate * fakeDeviceDelegate = [[MTRDeviceTestDelegate alloc] init];
2910
- fakeDeviceDelegate.pretendThreadEnabled = YES;
2911
-
2912
- @autoreleasepool {
2913
- // Create our fake device and have it dealloc before the blocking WorkItem
2914
- // completes and hence before its subscription work item gets a chance
2915
- // to run (in the width-1 case).
2916
-
2917
- // onSubscriptionCallbackDelete is called from dealloc
2918
- fakeDeviceDelegate.onSubscriptionCallbackDelete = ^{
2919
- [fakeDeviceDeletedExpectation fulfill];
2920
- };
2921
-
2922
- NSNumber * fakeDeviceID = @(0xFFFFFFFFFFFFFFFF);
2923
- __auto_type * device = [MTRDevice deviceWithNodeID:fakeDeviceID controller:controller];
2924
- [device setDelegate:fakeDeviceDelegate queue:queue];
2893
+ if (subscriptionPoolSize == 1) {
2894
+ // We have one fake device, which we use an invalid node ID for, that we use
2895
+ // to test what happens if a device is deallocated while its subscription
2896
+ // work item is queued. It should not block other things from running.
2897
+ //
2898
+ // Schedule a job in the controller's pool that will not complete until the
2899
+ // fake device is deallocated.
2900
+ __auto_type * fakeDeviceDeletedExpectation = [self expectationWithDescription:@"Fake device deleted"];
2901
+ MTRAsyncWorkItem * blockingWorkItem = [[MTRAsyncWorkItem alloc] initWithQueue:queue];
2902
+ [blockingWorkItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {
2903
+ [self waitForExpectations:@[ fakeDeviceDeletedExpectation ] timeout:kTimeoutInSeconds];
2904
+ completion(MTRAsyncWorkComplete);
2905
+ }];
2906
+ [controller.concurrentSubscriptionPool enqueueWorkItem:blockingWorkItem description:@"Waiting for fake device deletion"];
2907
+
2908
+ // Make sure the delegate for the fake device does not go away before the
2909
+ // fake device does, so keep it out of the @autoreleasepool block.
2910
+ MTRDeviceTestDelegate * fakeDeviceDelegate = [[MTRDeviceTestDelegate alloc] init];
2911
+ fakeDeviceDelegate.pretendThreadEnabled = YES;
2912
+
2913
+ @autoreleasepool {
2914
+ // Create our fake device and have it dealloc before the blocking WorkItem
2915
+ // completes and hence before its subscription work item gets a chance
2916
+ // to run (in the width-1 case).
2917
+
2918
+ // onSubscriptionCallbackDelete is called from dealloc
2919
+ fakeDeviceDelegate.onSubscriptionCallbackDelete = ^{
2920
+ [fakeDeviceDeletedExpectation fulfill];
2921
+ };
2922
+
2923
+ NSNumber * fakeDeviceID = @(0xFFFFFFFFFFFFFFFF);
2924
+ __auto_type * device = [MTRDevice deviceWithNodeID:fakeDeviceID controller:controller];
2925
+ [device setDelegate:fakeDeviceDelegate queue:queue];
2926
+ }
2925
2927
}
2926
2928
2927
2929
for (NSNumber * deviceID in orderedDeviceIDs) {
0 commit comments