mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
c6d44e59e2
- Using same clang format file for old and new files. - Moving out all TextSecure code to allow other clients (OS X, iOS) to integrate easily TextSecure functionality. - Use TextSecure API to signup.
53 lines
1.3 KiB
Objective-C
53 lines
1.3 KiB
Objective-C
#import "Util.h"
|
|
|
|
@implementation Operation
|
|
|
|
+ (Operation *)operation:(Action)block {
|
|
ows_require(block != NULL);
|
|
Operation *a = [Operation new];
|
|
a->_callback = block;
|
|
return a;
|
|
}
|
|
|
|
+ (void)asyncRun:(Action)action onThread:(NSThread *)thread {
|
|
ows_require(action != nil);
|
|
ows_require(thread != nil);
|
|
|
|
[[Operation operation:action] performOnThread:thread];
|
|
}
|
|
|
|
+ (void)asyncRunAndWaitUntilDone:(Action)action onThread:(NSThread *)thread {
|
|
ows_require(action != nil);
|
|
ows_require(thread != nil);
|
|
|
|
[[Operation operation:action] performOnThreadAndWaitUntilDone:thread];
|
|
}
|
|
|
|
+ (void)asyncRunOnNewThread:(Action)action {
|
|
ows_require(action != nil);
|
|
[[Operation operation:action] performOnNewThread];
|
|
}
|
|
|
|
- (SEL)selectorToRun {
|
|
return @selector(run);
|
|
}
|
|
|
|
- (void)performOnThread:(NSThread *)thread {
|
|
ows_require(thread != nil);
|
|
[self performSelector:@selector(run) onThread:thread withObject:nil waitUntilDone:thread == NSThread.currentThread];
|
|
}
|
|
|
|
- (void)performOnThreadAndWaitUntilDone:(NSThread *)thread {
|
|
ows_require(thread != nil);
|
|
[self performSelector:@selector(run) onThread:thread withObject:nil waitUntilDone:true];
|
|
}
|
|
|
|
- (void)performOnNewThread {
|
|
[NSThread detachNewThreadSelector:[self selectorToRun] toTarget:self withObject:nil];
|
|
}
|
|
|
|
- (void)run {
|
|
_callback();
|
|
}
|
|
|
|
@end
|