Skip to content

Commit

Permalink
Compilation issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
kzaher committed Oct 15, 2016
1 parent 5901064 commit 3a5eb3a
Show file tree
Hide file tree
Showing 8 changed files with 758 additions and 726 deletions.
17 changes: 9 additions & 8 deletions Platform/Platform.Linux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Glibc
import SwiftShims

final class AtomicInt: ExpressibleByIntegerLiteral {
final class AtomicInt {
typealias IntegerLiteralType = Int
fileprivate var value: Int32 = 0
fileprivate var _lock = NSRecursiveLock()
Expand All @@ -35,31 +35,32 @@
}

extension AtomicInt: ExpressibleByIntegerLiteral {
init(integerLiteral value: Int) {
self.value = value
convenience init(integerLiteral value: Int) {
self.init()
self.value = Int32(value)
}
}

func >(lhs: AtomicInt, rhs: Int) -> Bool {
func >(lhs: AtomicInt, rhs: Int32) -> Bool {
return lhs.value > rhs
}
func ==(lhs: AtomicInt, rhs: Int) -> Bool {
func ==(lhs: AtomicInt, rhs: Int32) -> Bool {
return lhs.value == rhs
}

func AtomicIncrement(_ atomic: inout AtomicInt) -> Int {
func AtomicIncrement(_ atomic: inout AtomicInt) -> Int32 {
atomic.lock(); defer { atomic.unlock() }
atomic.value += 1
return atomic.value
}

func AtomicDecrement(_ atomic: inout AtomicInt) -> Int {
func AtomicDecrement(_ atomic: inout AtomicInt) -> Int32 {
atomic.lock(); defer { atomic.unlock() }
atomic.value -= 1
return atomic.value
}

func AtomicCompareAndSwap(_ l: Int, _ r: Int, _ atomic: inout AtomicInt) -> Bool {
func AtomicCompareAndSwap(_ l: Int32, _ r: Int32, _ atomic: inout AtomicInt) -> Bool {
atomic.lock(); defer { atomic.unlock() }
if atomic.value == l {
atomic.value = r
Expand Down
10 changes: 6 additions & 4 deletions RxBlocking/RunLoopLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import CoreFoundation
#endif

#if os(Linux)
let runLoopMode: CFTypeRef = RunLoopMode.defaultRunLoopMode.rawValue as! CFString
let runLoopMode: RunLoopMode = RunLoopMode.defaultRunLoopMode
let runLoopModeRaw: CFString = unsafeBitCast(runLoopMode.rawValue._bridgeToObjectiveC(), to: CFString.self)
#else
let runLoopMode: CFRunLoopMode = CFRunLoopMode.defaultMode
let runLoopModeRaw = runLoopMode.rawValue
#endif

class RunLoopLock {
Expand All @@ -32,7 +34,7 @@ class RunLoopLock {
}

func dispatch(_ action: @escaping () -> ()) {
CFRunLoopPerformBlock(_currentRunLoop, runLoopMode.rawValue) {
CFRunLoopPerformBlock(_currentRunLoop, runLoopModeRaw) {
if CurrentThreadScheduler.isScheduleRequired {
_ = CurrentThreadScheduler.instance.schedule(()) { _ in
action()
Expand All @@ -50,7 +52,7 @@ class RunLoopLock {
if AtomicIncrement(&_calledStop) != 1 {
return
}
CFRunLoopPerformBlock(_currentRunLoop, runLoopMode.rawValue) {
CFRunLoopPerformBlock(_currentRunLoop, runLoopModeRaw) {
CFRunLoopStop(self._currentRunLoop)
}
CFRunLoopWakeUp(_currentRunLoop)
Expand All @@ -62,7 +64,7 @@ class RunLoopLock {
}
if let timeout = _timeout {
#if os(Linux)
switch Int(CFRunLoopRunInMode(runLoopMode, timeout, false)) {
switch Int(CFRunLoopRunInMode(runLoopModeRaw, timeout, false)) {
case kCFRunLoopRunFinished:
return
case kCFRunLoopRunHandledSource:
Expand Down
6 changes: 3 additions & 3 deletions RxSwift/Observables/Implementations/ObserveOn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ObserveOnSink<O: ObserverType> : ObserverBase<O.E> {
let _scheduler: ImmediateSchedulerType

var _lock = SpinLock()
let _observer: O?
let _observer: O

// state
var _state = ObserveOnState.stopped
Expand Down Expand Up @@ -81,7 +81,7 @@ class ObserveOnSink<O: ObserverType> : ObserverBase<O.E> {
}

func run(_ state: Void, recurse: (Void) -> Void) {
let (nextEvent, observer) = self._lock.calculateLocked { () -> (Event<E>?, O?) in
let (nextEvent, observer) = self._lock.calculateLocked { () -> (Event<E>?, O) in
if self._queue.count > 0 {
return (self._queue.dequeue(), self._observer)
}
Expand All @@ -92,7 +92,7 @@ class ObserveOnSink<O: ObserverType> : ObserverBase<O.E> {
}

if let nextEvent = nextEvent, !_cancel.isDisposed {
observer?.on(nextEvent)
observer.on(nextEvent)
if nextEvent.isStopEvent {
dispose()
}
Expand Down
6 changes: 2 additions & 4 deletions RxSwift/Schedulers/CurrentThreadScheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ public class CurrentThreadScheduler : ImmediateSchedulerType {

let scheduledItem = ScheduledItem(action: action, state: state)
queue.value.enqueue(scheduledItem)

// In Xcode 7.3, `return scheduledItem` causes segmentation fault 11 on release build.
// To workaround this compiler issue, returns AnonymousDisposable that disposes scheduledItem.
return Disposables.create(with: scheduledItem.dispose)

return scheduledItem
}
}
Loading

0 comments on commit 3a5eb3a

Please sign in to comment.