DispatchQueue
public extension DispatchQueue
-
Executes a block of code, associated with a unique token, only once.
The code is thread safe and will only execute the block once even in the presence of multithreaded calls.
Declaration
Swift
class func once(token: String = "\(#file).\(#function):\(#line)", block: @escaping @Sendable () -> Void)
Parameters
token
A unique token as key for the block. Use a unique reverse DNS style name such as com.vectorform.
or a string representation of a UUID. Defaults to a token created out of the file name, function name and the line number of the method’s call. block
Block to execute once.