diff --git a/SignalServiceKit/src/Util/AppReadiness.m b/SignalServiceKit/src/Util/AppReadiness.m index 95ba13e7c..44a68cfe9 100755 --- a/SignalServiceKit/src/Util/AppReadiness.m +++ b/SignalServiceKit/src/Util/AppReadiness.m @@ -3,6 +3,7 @@ // #import "AppReadiness.h" +#import "Threading.h" NS_ASSUME_NONNULL_BEGIN @@ -48,9 +49,9 @@ NS_ASSUME_NONNULL_BEGIN + (void)runNowOrWhenAppIsReady:(AppReadyBlock)block { - OWSAssertIsOnMainThread(); - - [self.sharedManager runNowOrWhenAppIsReady:block]; + DispatchMainThreadSafe(^{ + [self.sharedManager runNowOrWhenAppIsReady:block]; + }); } - (void)runNowOrWhenAppIsReady:(AppReadyBlock)block diff --git a/SignalServiceKit/src/Util/Threading.h b/SignalServiceKit/src/Util/Threading.h index 4aac9cec7..dca1d19a7 100644 --- a/SignalServiceKit/src/Util/Threading.h +++ b/SignalServiceKit/src/Util/Threading.h @@ -4,16 +4,14 @@ NS_ASSUME_NONNULL_BEGIN -typedef void (^SimpleBlock)(void); - // The block is executed immediately if called from the // main thread; otherwise it is dispatched async to the // main thread. -void DispatchMainThreadSafe(SimpleBlock block); +void DispatchMainThreadSafe(dispatch_block_t block); // The block is executed immediately if called from the // main thread; otherwise it is dispatched sync to the // main thread. -void DispatchSyncMainThreadSafe(SimpleBlock block); +void DispatchSyncMainThreadSafe(dispatch_block_t block); NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Util/Threading.m b/SignalServiceKit/src/Util/Threading.m index 72505e339..be0f00501 100644 --- a/SignalServiceKit/src/Util/Threading.m +++ b/SignalServiceKit/src/Util/Threading.m @@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN -void DispatchMainThreadSafe(SimpleBlock block) +void DispatchMainThreadSafe(dispatch_block_t block) { OWSCAssert(block); @@ -19,7 +19,7 @@ void DispatchMainThreadSafe(SimpleBlock block) } } -void DispatchSyncMainThreadSafe(SimpleBlock block) +void DispatchSyncMainThreadSafe(dispatch_block_t block) { OWSCAssert(block);