Created
March 12, 2016 19:54
-
-
Save stefc/7fe2c90b92b5e63bc259 to your computer and use it in GitHub Desktop.
sequence for generate int32 identifiers in Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// IdGenerator.swift | |
// Created by Stefan Böther on 21.12.15. | |
// | |
import Foundation | |
class IdSequence : SequenceType { | |
func generate() -> AnyGenerator<Int32> { | |
var value : Int32 = 0 | |
return anyGenerator { | |
return OSAtomicIncrement32(&value) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment