Fixes compilation on Linux.
This commit is contained in:
parent
db5959fc6e
commit
a7d96765d6
|
|
@ -11,11 +11,28 @@ import Foundation
|
|||
import RxSwift
|
||||
#endif
|
||||
|
||||
typealias AtomicInt = Int32
|
||||
|
||||
#if os(Linux)
|
||||
func AtomicIncrement(increment: UnsafeMutablePointer<AtomicInt>) -> AtomicInt {
|
||||
increment.memory = increment.memory + 1
|
||||
return increment.memory
|
||||
}
|
||||
|
||||
func AtomicDecrement(increment: UnsafeMutablePointer<AtomicInt>) -> AtomicInt {
|
||||
increment.memory = increment.memory - 1
|
||||
return increment.memory
|
||||
}
|
||||
#else
|
||||
let AtomicIncrement = OSAtomicIncrement32
|
||||
let AtomicDecrement = OSAtomicDecrement32
|
||||
#endif
|
||||
|
||||
class RunLoopLock {
|
||||
let currentRunLoop: CFRunLoopRef
|
||||
|
||||
var calledRun: Int32 = 0
|
||||
var calledStop: Int32 = 0
|
||||
var calledRun: AtomicInt = 0
|
||||
var calledStop: AtomicInt = 0
|
||||
|
||||
init() {
|
||||
currentRunLoop = CFRunLoopGetCurrent()
|
||||
|
|
@ -37,7 +54,7 @@ class RunLoopLock {
|
|||
}
|
||||
|
||||
func stop() {
|
||||
if OSAtomicIncrement32(&calledStop) != 1 {
|
||||
if AtomicIncrement(&calledStop) != 1 {
|
||||
return
|
||||
}
|
||||
CFRunLoopPerformBlock(currentRunLoop, kCFRunLoopDefaultMode) {
|
||||
|
|
@ -47,7 +64,7 @@ class RunLoopLock {
|
|||
}
|
||||
|
||||
func run() {
|
||||
if OSAtomicIncrement32(&calledRun) != 1 {
|
||||
if AtomicIncrement(&calledRun) != 1 {
|
||||
fatalError("Run can be only called once")
|
||||
}
|
||||
CFRunLoopRun()
|
||||
|
|
|
|||
Loading…
Reference in New Issue