summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-11-06 15:09:28 -0500
committerJoel Fischer <joeljfischer@gmail.com>2020-11-06 15:09:28 -0500
commit76f9a87109830c0295a680cc5d820a87daa96de7 (patch)
tree081e972b3a2c1c1df81f57ce22e58cfe731e9519
parente414b6061ea30704994dad1bf6377019632b8b71 (diff)
downloadsdl_ios-76f9a87109830c0295a680cc5d820a87daa96de7.tar.gz
Creating the transaction queue
-rw-r--r--SmartDeviceLink/private/SDLVoiceCommandManager.m29
1 files changed, 22 insertions, 7 deletions
diff --git a/SmartDeviceLink/private/SDLVoiceCommandManager.m b/SmartDeviceLink/private/SDLVoiceCommandManager.m
index 6f59d1d1e..47182b905 100644
--- a/SmartDeviceLink/private/SDLVoiceCommandManager.m
+++ b/SmartDeviceLink/private/SDLVoiceCommandManager.m
@@ -34,13 +34,11 @@ NS_ASSUME_NONNULL_BEGIN
@interface SDLVoiceCommandManager()
@property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager;
+@property (strong, nonatomic) NSOperationQueue *transactionQueue;
@property (assign, nonatomic) BOOL waitingOnHMIUpdate;
@property (copy, nonatomic, nullable) SDLHMILevel currentHMILevel;
-@property (strong, nonatomic, nullable) NSArray<SDLRPCRequest *> *inProgressUpdate;
-@property (assign, nonatomic) BOOL hasQueuedUpdate;
-
@property (assign, nonatomic) UInt32 lastVoiceCommandId;
@property (copy, nonatomic) NSArray<SDLVoiceCommand *> *currentVoiceCommands;
@@ -55,6 +53,7 @@ UInt32 const VoiceCommandIdMin = 1900000000;
if (!self) { return nil; }
_lastVoiceCommandId = VoiceCommandIdMin;
+ _transactionQueue = [self sdl_newTransactionQueue];
_voiceCommands = @[];
_currentVoiceCommands = @[];
@@ -77,11 +76,20 @@ UInt32 const VoiceCommandIdMin = 1900000000;
_lastVoiceCommandId = VoiceCommandIdMin;
_voiceCommands = @[];
_currentVoiceCommands = @[];
+ _transactionQueue = [self sdl_newTransactionQueue];
_waitingOnHMIUpdate = NO;
_currentHMILevel = nil;
- _inProgressUpdate = nil;
- _hasQueuedUpdate = NO;
+}
+
+- (NSOperationQueue *)sdl_newTransactionQueue {
+ NSOperationQueue *queue = [[NSOperationQueue alloc] init];
+ queue.name = @"SDLVoiceCommandManager Transaction Queue";
+ queue.maxConcurrentOperationCount = 1;
+ queue.qualityOfService = NSQualityOfServiceUserInitiated;
+ queue.suspended = YES;
+
+ return queue;
}
#pragma mark - Setters
@@ -98,9 +106,16 @@ UInt32 const VoiceCommandIdMin = 1900000000;
_voiceCommands = voiceCommands;
- [SDLVoiceCommandUpdateOperation *updateOperation = [[SDLVoiceCommandUpdateOperation alloc] initWithConnectionManager:self.connectionManager newVoiceCommands:voiceCommands oldVoiceCommands:_currentVoiceCommands updateCompletionHandler:^(NSError * _Nullable error) {
- // TODO
+ __weak typeof(self) weakSelf = self;
+ SDLVoiceCommandUpdateOperation *updateOperation = [[SDLVoiceCommandUpdateOperation alloc] initWithConnectionManager:self.connectionManager newVoiceCommands:voiceCommands oldVoiceCommands:_currentVoiceCommands updateCompletionHandler:^(NSError * _Nullable error) {
+ if (error != nil) {
+ return;
+ }
+
+ weakSelf.currentVoiceCommands = voiceCommands;
}];
+
+ [self.transactionQueue addOperation:updateOperation];
}
#pragma mark - Helpers