mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
674 B
Objective-C
37 lines
674 B
Objective-C
//
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "Threading.h"
|
|
#import <SessionProtocolKit/OWSAsserts.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
void DispatchMainThreadSafe(dispatch_block_t block)
|
|
{
|
|
OWSCAssertDebug(block);
|
|
|
|
if ([NSThread isMainThread]) {
|
|
block();
|
|
} else {
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
block();
|
|
});
|
|
}
|
|
}
|
|
|
|
void DispatchSyncMainThreadSafe(dispatch_block_t block)
|
|
{
|
|
OWSCAssertDebug(block);
|
|
|
|
if ([NSThread isMainThread]) {
|
|
block();
|
|
} else {
|
|
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
block();
|
|
});
|
|
}
|
|
}
|
|
|
|
NS_ASSUME_NONNULL_END
|