
import Foundation

/*
	Credits:
	https://github.com/future-challenger/Swift3.0/tree/master/GCD
*/

public extension DispatchQueue {
	private static var onceTracker = [String]()

	///	Execute the given `block` only once during app's lifecycle
    typealias Block = () -> Void
	public class func once(token: String, block: @escaping Block) {
		objc_sync_enter(self);
		defer {
			objc_sync_exit(self)
		}

		if onceTracker.contains(token) { return }
		onceTracker.append(token)
		block()
	}
}
