Skip to content

Commit 86e1974

Browse files
authored
[Darwin] Remove Matter framework main queue usage (#35492)
1 parent 01632c4 commit 86e1974

4 files changed

+5
-5
lines changed

src/darwin/Framework/CHIP/MTRDeviceController.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams
845845
//
846846
// Note that this is just an optimization to avoid throwing the information away and immediately
847847
// re-reading it from storage.
848-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (kSecondsToWaitBeforeAPIClientRetainsMTRDevice * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
848+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (kSecondsToWaitBeforeAPIClientRetainsMTRDevice * NSEC_PER_SEC)), self.chipWorkQueue, ^{
849849
MTR_LOG("%@ un-retain devices loaded at startup %lu", self, static_cast<unsigned long>(deviceList.count));
850850
});
851851
}];

src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams
761761
//
762762
// Note that this is just an optimization to avoid throwing the information away and immediately
763763
// re-reading it from storage.
764-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (kSecondsToWaitBeforeAPIClientRetainsMTRDevice * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
764+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (kSecondsToWaitBeforeAPIClientRetainsMTRDevice * NSEC_PER_SEC)), self.chipWorkQueue, ^{
765765
MTR_LOG("%@ un-retain devices loaded at startup %lu", self, static_cast<unsigned long>(deviceList.count));
766766
});
767767
}];

src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ - (void)_startXPCConnectionRetry
115115
self.xpcRetryTimeInterval = 0.5;
116116
mtr_weakify(self);
117117

118-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (self.xpcRetryTimeInterval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
118+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (self.xpcRetryTimeInterval * NSEC_PER_SEC)), self.chipWorkQueue, ^{
119119
mtr_strongify(self);
120120
[self _xpcConnectionRetry];
121121
});
@@ -135,7 +135,7 @@ - (void)_xpcConnectionRetry
135135
self.xpcRetryTimeInterval = MIN(60.0, self.xpcRetryTimeInterval);
136136
mtr_weakify(self);
137137

138-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.xpcRetryTimeInterval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
138+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.xpcRetryTimeInterval * NSEC_PER_SEC)), self.chipWorkQueue, ^{
139139
mtr_strongify(self);
140140
[self _xpcConnectionRetry];
141141
});

src/darwin/Framework/CHIP/MTRDevice_Concrete.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
11651165
}
11661166

11671167
// Wait the required amount of time, then put it in the subscription pool to wait additionally for a spot, if needed
1168-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, inNanoseconds), dispatch_get_main_queue(), ^{
1168+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, inNanoseconds), self.queue, ^{
11691169
// In the case where a resubscription triggering event happened and already established, running the work block should result in a no-op
11701170
MTRAsyncWorkItem * workItem = [[MTRAsyncWorkItem alloc] initWithQueue:self.queue];
11711171
[workItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {

0 commit comments

Comments
 (0)