Add PromiseKit dependency

- Added PromiseKit dependency
This commit is contained in:
2018-11-15 22:08:00 -04:00
parent 2689d86c18
commit be7b6b5881
541 changed files with 46282 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
#import "AnyPromise.h"
#import "AnyPromise+Private.h"
@import CoreFoundation.CFRunLoop;
/**
Suspends the active thread waiting on the provided promise.
@return The value of the provided promise once resolved.
*/
id PMKHang(AnyPromise *promise) {
if (promise.pending) {
static CFRunLoopSourceContext context;
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
CFRunLoopSourceRef runLoopSource = CFRunLoopSourceCreate(NULL, 0, &context);
CFRunLoopAddSource(runLoop, runLoopSource, kCFRunLoopDefaultMode);
promise.ensure(^{
CFRunLoopStop(runLoop);
});
while (promise.pending) {
CFRunLoopRun();
}
CFRunLoopRemoveSource(runLoop, runLoopSource, kCFRunLoopDefaultMode);
CFRelease(runLoopSource);
}
return promise.value;
}