summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLLifecycleManager.m
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2019-05-16 15:34:16 -0400
committerJoel Fischer <joeljfischer@gmail.com>2019-05-16 15:34:16 -0400
commit8ad6111f111df3defbfeeac2e0f929f68e263eac (patch)
treeb33b02cf81dfa719ae41bb9863ea62fc60e4a278 /SmartDeviceLink/SDLLifecycleManager.m
parente1fbffb3b42f4bfa07fb92aef1e4c1cb5d812ff5 (diff)
downloadsdl_ios-8ad6111f111df3defbfeeac2e0f929f68e263eac.tar.gz
Move callbacks to the callback queue
Diffstat (limited to 'SmartDeviceLink/SDLLifecycleManager.m')
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m22
1 files changed, 12 insertions, 10 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index 484b0d164..da858d21a 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -592,9 +592,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
return;
}
- dispatch_async(_lifecycleQueue, ^{
- [self sdl_sendRequest:rpc withResponseHandler:nil];
- });
+ [self sdl_sendRequest:rpc withResponseHandler:nil];
}
- (void)sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler {
@@ -609,16 +607,12 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
return;
}
- dispatch_async(_lifecycleQueue, ^{
- [self sdl_sendRequest:request withResponseHandler:handler];
- });
+ [self sdl_sendRequest:request withResponseHandler:handler];
}
// Managers need to avoid state checking. Part of <SDLConnectionManagerType>.
- (void)sendConnectionManagerRequest:(__kindof SDLRPCMessage *)request withResponseHandler:(nullable SDLResponseHandler)handler {
- dispatch_async(_lifecycleQueue, ^{
- [self sdl_sendRequest:request withResponseHandler:handler];
- });
+ [self sdl_sendRequest:request withResponseHandler:handler];
}
- (void)sdl_sendRequest:(__kindof SDLRPCMessage *)request withResponseHandler:(nullable SDLResponseHandler)handler {
@@ -671,8 +665,16 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
}
// this is to make sure that the transition happens on the dedicated queue
-- (void)sdl_transitionToState:(SDLState *)state {
+- (void)sdl_runOnProcessingQueue:(void (^)(void))block {
+ if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(self.lifecycleQueue)) == 0
+ || strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label([SDLGlobals sharedGlobals].sdlProcessingQueue)) == 0) {
+ block();
+ } else {
+ dispatch_sync(self.lifecycleQueue, block);
+ }
+}
+- (void)sdl_transitionToState:(SDLState *)state {
if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(self.lifecycleQueue)) == 0
|| strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label([SDLGlobals sharedGlobals].sdlProcessingQueue)) == 0) {
[self.lifecycleStateMachine transitionToState:state];