| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | ////  ALMacros.h//  AppLovinSDK////  Created by Thomas So on 1/1/22.//NS_ASSUME_NONNULL_BEGINNS_INLINE BOOL isMainQueue (void){    return [NSThread isMainThread];}NS_INLINE void deferToNextMainQueueRunloop (void (^block)(void)){    [[NSOperationQueue mainQueue] addOperationWithBlock: block];}NS_INLINE void dispatchOnMainQueueNow (void (^block)(void)){    dispatch_async(dispatch_get_main_queue(), block);}NS_INLINE void dispatchOnMainQueue (void (^block)(void)){    if ( isMainQueue() )    {        block();    }    else    {        deferToNextMainQueueRunloop(block);    }}NS_INLINE void dispatchOnMainQueueImmediate (void (^block)(void)){    if ( isMainQueue () )    {        block();    }    else    {        dispatchOnMainQueueNow(block);    }}NS_INLINE void dispatchOnMainQueueAfter (double delay, dispatch_block_t __nonnull block){    if ( delay > 0 )    {        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (delay * NSEC_PER_SEC)), dispatch_get_main_queue(), block);    }    else    {        dispatchOnMainQueueImmediate(block);    }}NS_INLINE void dispatchOnMainQueueAfterAndDeferToNextMainQueueRunloop (double delay, dispatch_block_t __nonnull block){    if ( delay > 0 )    {        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (delay * NSEC_PER_SEC)), dispatch_get_main_queue(), block);    }    else    {        deferToNextMainQueueRunloop(block);    }}NS_INLINE void dispatchSyncOnMainQueue (dispatch_block_t __nonnull block){    // Cannot call dispatch_sync on same queue results in deadlock - so just run op if main queue already    if ( isMainQueue() )    {        block();    }    else    {        dispatch_sync(dispatch_get_main_queue(), block);    }}NS_INLINE void dispatchOnGlobalQueueAfter (dispatch_queue_priority_t priority, double delay, dispatch_block_t __nonnull block){    dispatch_queue_t globalQueue = dispatch_get_global_queue(priority, 0);        if ( delay > 0 )    {        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (delay * NSEC_PER_SEC)), globalQueue, block);    }    else    {        dispatch_async(globalQueue, block);    }}NS_ASSUME_NONNULL_END
 |