@@ -844,11 +844,13 @@ - (void)_addDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)que
844
844
#endif
845
845
846
846
if (shouldSetUpSubscription) {
847
+ MTR_LOG (" %@ - starting subscription setup" , self);
847
848
// Record the time of first addDelegate call that triggers initial subscribe, and do not reset this value on subsequent addDelegate calls
848
849
if (!_initialSubscribeStart) {
849
850
_initialSubscribeStart = [NSDate now ];
850
851
}
851
852
if ([self _deviceUsesThread ]) {
853
+ MTR_LOG (" => %@ - device is a thread device, scheduling in pool" , self);
852
854
[self _scheduleSubscriptionPoolWork: ^{
853
855
std::lock_guard lock (self->_lock );
854
856
[self _setupSubscriptionWithReason: @" delegate is set and scheduled subscription is happening" ];
@@ -1301,7 +1303,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
1301
1303
1302
1304
// Sanity check we are not scheduling for this device multiple times in the pool
1303
1305
if (_subscriptionPoolWorkCompletionBlock) {
1304
- MTR_LOG_ERROR (" %@ already scheduled in subscription pool for this device - ignoring: %@" , self, description);
1306
+ MTR_LOG (" %@ already scheduled in subscription pool for this device - ignoring: %@" , self, description);
1305
1307
return ;
1306
1308
}
1307
1309
@@ -1310,6 +1312,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
1310
1312
// In the case where a resubscription triggering event happened and already established, running the work block should result in a no-op
1311
1313
MTRAsyncWorkItem * workItem = [[MTRAsyncWorkItem alloc ] initWithQueue: self .queue];
1312
1314
[workItem setReadyHandler: ^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {
1315
+ MTR_LOG (" %@ - work item is ready to attempt pooled subscription" , self);
1313
1316
os_unfair_lock_lock (&self->_lock );
1314
1317
#ifdef DEBUG
1315
1318
[self _callDelegatesWithBlock: ^(id testDelegate) {
@@ -1335,6 +1338,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
1335
1338
workBlock ();
1336
1339
}];
1337
1340
[self ->_deviceController.concurrentSubscriptionPool enqueueWorkItem: workItem description: description];
1341
+ MTR_LOG (" %@ - enqueued in the subscription pool" , self);
1338
1342
});
1339
1343
}
1340
1344
0 commit comments