DispatchQueue

public extension DispatchQueue

Extenstion to DispatchQueue class.

  • Executes a block of code, associated with a unique token, only once. The code is thread safe and will only execute the code once even in the presence of multi-threaded calls.

    Declaration

    Swift

    class func once(token: String, block: () -> Void)
    Parameters
    token

    A unique name.

    block

    Block to execute once.