Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

Once

GitHub license Carthage compatibleSPM

A simple thread safe replacement for Dispatch Once and pthread_once for Swift.

Carthage Usage

Include this line in your Cartfile:

github "bscothern/Once"

Swift Package Manager

Update your Package.swift to include this to your package dependencies:

.package(url: "https://github.com/bscothern/Once.git", from: "1.3.2")

Usage

import Once

let once = Once()

func foo() {
    once.runOnce {
        // Do stuff that should only execute the first time foo() is called.
    }
    // Do stuff
}
You can’t perform that action at this time.