Upgrade version of RxSwift, RxCocoa, Alamofire.
This commit is contained in:
@ -50,7 +50,11 @@ public class CurrentThreadScheduler : ImmediateSchedulerType {
|
||||
|
||||
private static var isScheduleRequiredKey: pthread_key_t = { () -> pthread_key_t in
|
||||
let key = UnsafeMutablePointer<pthread_key_t>.allocate(capacity: 1)
|
||||
if pthread_key_create(key, nil) != 0 {
|
||||
defer {
|
||||
key.deallocate(capacity: 1)
|
||||
}
|
||||
|
||||
guard pthread_key_create(key, nil) == 0 else {
|
||||
rxFatalError("isScheduleRequired key creation failed")
|
||||
}
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
//
|
||||
// ImmediateScheduler.swift
|
||||
// RxSwift
|
||||
//
|
||||
// Created by Krunoslav Zaher on 10/17/15.
|
||||
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
/// Represents an object that schedules units of work to run immediately on the current thread.
|
||||
private final class ImmediateScheduler : ImmediateSchedulerType {
|
||||
|
||||
private let _asyncLock = AsyncLock<AnonymousInvocable>()
|
||||
|
||||
/**
|
||||
Schedules an action to be executed immediately.
|
||||
|
||||
In case `schedule` is called recursively from inside of `action` callback, scheduled `action` will be enqueued
|
||||
and executed after current `action`. (`AsyncLock` behavior)
|
||||
|
||||
- parameter state: State passed to the action to be executed.
|
||||
- parameter action: Action to be executed.
|
||||
- returns: The disposable object used to cancel the scheduled action (best effort).
|
||||
*/
|
||||
func schedule<StateType>(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable {
|
||||
let disposable = SingleAssignmentDisposable()
|
||||
_asyncLock.invoke(AnonymousInvocable {
|
||||
if disposable.isDisposed {
|
||||
return
|
||||
}
|
||||
disposable.setDisposable(action(state))
|
||||
})
|
||||
|
||||
return disposable
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
//
|
||||
// AnonymousInvocable.swift
|
||||
// RxSwift
|
||||
//
|
||||
// Created by Krunoslav Zaher on 11/7/15.
|
||||
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
struct AnonymousInvocable : InvocableType {
|
||||
private let _action: () -> ()
|
||||
|
||||
init(_ action: @escaping () -> ()) {
|
||||
_action = action
|
||||
}
|
||||
|
||||
func invoke() {
|
||||
_action()
|
||||
}
|
||||
}
|
@ -43,7 +43,11 @@ extension DispatchQueueConfiguration {
|
||||
let compositeDisposable = CompositeDisposable()
|
||||
|
||||
let timer = DispatchSource.makeTimerSource(queue: queue)
|
||||
timer.scheduleOneshot(deadline: deadline)
|
||||
#if swift(>=4.0)
|
||||
timer.schedule(deadline: deadline, leeway: leeway)
|
||||
#else
|
||||
timer.scheduleOneshot(deadline: deadline, leeway: leeway)
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
// This looks horrible, and yes, it is.
|
||||
@ -77,8 +81,12 @@ extension DispatchQueueConfiguration {
|
||||
var timerState = state
|
||||
|
||||
let timer = DispatchSource.makeTimerSource(queue: queue)
|
||||
timer.scheduleRepeating(deadline: initial, interval: dispatchInterval(period), leeway: leeway)
|
||||
|
||||
#if swift(>=4.0)
|
||||
timer.schedule(deadline: initial, repeating: dispatchInterval(period), leeway: leeway)
|
||||
#else
|
||||
timer.scheduleRepeating(deadline: initial, interval: dispatchInterval(period), leeway: leeway)
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
// This looks horrible, and yes, it is.
|
||||
// It looks like Apple has made a conceputal change here, and I'm unsure why.
|
||||
|
@ -40,7 +40,7 @@ public final class MainScheduler : SerialDispatchQueueScheduler {
|
||||
/// In case this method is called on a background thread it will throw an exception.
|
||||
public class func ensureExecutingOnScheduler(errorMessage: String? = nil) {
|
||||
if !DispatchQueue.isMain {
|
||||
rxFatalError(errorMessage ?? "Executing on backgound thread. Please use `MainScheduler.instance.schedule` to schedule work on main thread.")
|
||||
rxFatalError(errorMessage ?? "Executing on background thread. Please use `MainScheduler.instance.schedule` to schedule work on main thread.")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user