Created
February 6, 2015 00:30
-
-
Save pwightman/43cce849f7152842f03c to your computer and use it in GitHub Desktop.
This file contains 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
class Locks { | |
private var queuedDocuments = [String:Document]() | |
private var inFlightDocuments = [String:Document]() | |
private let queuedQueue = dispatch_queue_create("com.lucidchart.DocumentStateStoreLocks.queued", DISPATCH_QUEUE_SERIAL) | |
private let inFlightQueue = dispatch_queue_create("com.lucidchart.DocumentStateStoreLocks.inFlight", DISPATCH_QUEUE_SERIAL) | |
func queued(block: [String:Document] -> [String:Document]) { | |
dispatch_sync(queuedQueue) { | |
self.queuedDocuments = block(self.queuedDocuments) | |
} | |
} | |
func inFlight(block: [String:Document] -> [String:Document]) { | |
dispatch_sync(inFlightQueue) { | |
self.inFlightDocuments = block(self.inFlightDocuments) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment