Last active
August 29, 2015 14:12
-
-
Save prachigauriar/0ababa76f74edfd43f54 to your computer and use it in GitHub Desktop.
Synchronous Subworkflow Task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SynchronousSubworkflowTask.h | |
// SynchronousSubworkflowTask | |
// | |
// Created by Prachi Gauriar on 1/5/2015. | |
// Copyright (c) 2015 Prachi Gauriar. All rights reserved. | |
// | |
#import <Task/Task.h> | |
@interface SynchronousSubworkflowTask : TSKSubworkflowTask | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SynchronousSubworkflowTask.m | |
// SynchronousSubworkflowTask | |
// | |
// Created by Prachi Gauriar on 1/5/2015. | |
// Copyright (c) 2015 Prachi Gauriar. All rights reserved. | |
// | |
#import "SynchronousSubworkflowTask.h" | |
@interface SynchronousSubworkflowTask () | |
@property (nonatomic, strong) dispatch_group_t dispatchGroup; | |
@end | |
@implementation SynchronousSubworkflowTask | |
- (instancetype)initWithName:(NSString *)name subworkflow:(TSKWorkflow *)subworkflow | |
{ | |
self = [super initWithName:name subworkflow:subworkflow]; | |
if (self) { | |
_dispatchGroup = dispatch_group_create(); | |
} | |
return self; | |
} | |
- (void)main | |
{ | |
dispatch_group_enter(self.dispatchGroup); | |
[super main]; | |
dispatch_group_wait(self.dispatchGroup, DISPATCH_TIME_FOREVER); | |
} | |
- (void)didFinishWithResult:(id)result | |
{ | |
dispatch_group_leave(self.dispatchGroup); | |
} | |
- (void)didFailWithError:(NSError *)error | |
{ | |
dispatch_group_leave(self.dispatchGroup); | |
} | |
- (void)didCancel | |
{ | |
dispatch_group_leave(self.dispatchGroup); | |
} | |
- (void)didReset | |
{ | |
dispatch_group_leave(self.dispatchGroup); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment