This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| /// An abstract class that makes building simple asynchronous operations easy. | |
| /// Subclasses must implement `execute()` to perform any work and call | |
| /// `finish()` when they are done. All `NSOperation` work will be handled | |
| /// automatically. | |
| open class AsynchronousOperation: Operation { | |
| // MARK: - Properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Semaphore { | |
| let semaphore: dispatch_semaphore_t | |
| init(value: Int = 0) { | |
| semaphore = dispatch_semaphore_create(value) | |
| } | |
| // Blocks the thread until the semaphore is free and returns true | |
| // or until the timeout passes and returns false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Semaphore { | |
| let semaphore: dispatch_semaphore_t | |
| init(value: Int = 0) { | |
| semaphore = dispatch_semaphore_create(value) | |
| } | |
| // Blocks the thread until the semaphore is free and returns true | |
| // or until the timeout passes and returns false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Taken from the commercial iOS PDF framework http://pspdfkit.com. | |
| // Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
| // Licensed under MIT (http://opensource.org/licenses/MIT) | |
| // | |
| // You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
| #import <objc/runtime.h> | |
| #import <objc/message.h> | |
| // Compile-time selector checks. |