Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created June 12, 2020 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/6f6f9e9a744267dd64d6186dded79a44 to your computer and use it in GitHub Desktop.
Save stevencurtis/6f6f9e9a744267dd64d6186dded79a44 to your computer and use it in GitHub Desktop.
queuemanager
class QueueManager {
/// The Lazily-instantiated queue
lazy var queue: OperationQueue = {
let queue = OperationQueue()
return queue;
}()
/// The Singleton Instance
static let sharedInstance = QueueManager()
/// Add a single operation
/// - Parameter operation: The operation to be added
func enqueue(_ operation: Operation) {
queue.addOperation(operation)
}
/// Add an array of operations
/// - Parameter operations: The Array of Operation to be added
func addOperations(_ operations: [Operation]) {
queue.addOperations(operations, waitUntilFinished: true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment