Skip to content

Commit

Permalink
Merge with 'swift-3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenr committed Aug 10, 2016
2 parents f8a11aa + 2498b31 commit f1b4e0f
Show file tree
Hide file tree
Showing 36 changed files with 170 additions and 161 deletions.
2 changes: 1 addition & 1 deletion Documentation/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func myInterval(interval: NSTimeInterval) -> Observable<Int> {
dispatch_source_cancel(timer)
}
dispatch_source_set_event_handler(timer, {
if cancel.disposed {
if cancel.isDisposed {
return
}
observer.on(.Next(next))
Expand Down
16 changes: 8 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import PackageDescription
#if os(OSX)
let package = Package(
name: "RxSwift",
exclude: [
"Sources/RxCocoa",
"Sources/RxTests",
"Sources/AllTests"
],
targets: [
Target(
name: "RxSwift"
Expand All @@ -32,14 +27,16 @@ let package = Package(
.Target(name: "RxTests")
]
)
],
exclude: [
"Sources/RxCocoa",
"Sources/RxTests",
"Sources/AllTests"
]
)
#elseif os(Linux)
let package = Package(
name: "RxSwift",
exclude: [
"Sources/RxCocoa",
],
targets: [
Target(
name: "RxSwift"
Expand All @@ -64,6 +61,9 @@ let package = Package(
.Target(name: "RxTests")
]
)
],
exclude: [
"Sources/RxCocoa",
]
)
#endif
8 changes: 4 additions & 4 deletions RxBlocking/BlockingObservable+Operators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension BlockingObservable {

lock.dispatch {
d.disposable = self.source.subscribe { e in
if d.disposed {
if d.isDisposed {
return
}
switch e {
Expand Down Expand Up @@ -78,7 +78,7 @@ extension BlockingObservable {

lock.dispatch {
d.disposable = self.source.subscribe { e in
if d.disposed {
if d.isDisposed {
return
}

Expand Down Expand Up @@ -130,7 +130,7 @@ extension BlockingObservable {

lock.dispatch {
d.disposable = self.source.subscribe { e in
if d.disposed {
if d.isDisposed {
return
}
switch e {
Expand Down Expand Up @@ -191,7 +191,7 @@ extension BlockingObservable {

lock.dispatch {
d.disposable = self.source.subscribe { e in
if d.disposed {
if d.isDisposed {
return
}
switch e {
Expand Down
11 changes: 10 additions & 1 deletion RxSwift/Cancelable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@ public protocol Cancelable : Disposable {
/**
- returns: Was resource disposed.
*/
var disposed: Bool { get }
var isDisposed: Bool { get }
}

public extension Cancelable {

@available(*, deprecated, renamed: "isDisposed")
var disposed: Bool {
return isDisposed
}

}
10 changes: 5 additions & 5 deletions RxSwift/Disposables/AnonymousDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ When dispose method is called, disposal action will be dereferenced.
public final class AnonymousDisposable : DisposeBase, Cancelable {
public typealias DisposeAction = () -> Void

private var _disposed: AtomicInt = 0
private var _isDisposed: AtomicInt = 0
private var _disposeAction: DisposeAction?

/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed == 1
public var isDisposed: Bool {
return _isDisposed == 1
}

/**
Expand All @@ -49,8 +49,8 @@ public final class AnonymousDisposable : DisposeBase, Cancelable {
After invoking disposal action, disposal action will be dereferenced.
*/
public func dispose() {
if AtomicCompareAndSwap(0, 1, &_disposed) {
assert(_disposed == 1)
if AtomicCompareAndSwap(0, 1, &_isDisposed) {
assert(_isDisposed == 1)

if let action = _disposeAction {
_disposeAction = nil
Expand Down
8 changes: 4 additions & 4 deletions RxSwift/Disposables/BinaryDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Represents two disposable resources that are disposed together.
*/
private final class BinaryDisposable : DisposeBase, Cancelable {

private var _disposed: AtomicInt = 0
private var _isDisposed: AtomicInt = 0

// state
private var _disposable1: Disposable?
Expand All @@ -22,8 +22,8 @@ private final class BinaryDisposable : DisposeBase, Cancelable {
/**
- returns: Was resource disposed.
*/
var disposed: Bool {
return _disposed > 0
var isDisposed: Bool {
return _isDisposed > 0
}

/**
Expand All @@ -44,7 +44,7 @@ private final class BinaryDisposable : DisposeBase, Cancelable {
After invoking disposal action, disposal action will be dereferenced.
*/
func dispose() {
if AtomicCompareAndSwap(0, 1, &_disposed) {
if AtomicCompareAndSwap(0, 1, &_isDisposed) {
_disposable1?.dispose()
_disposable2?.dispose()
_disposable1 = nil
Expand Down
18 changes: 9 additions & 9 deletions RxSwift/Disposables/BooleanDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Represents a disposable resource that can be checked for disposal status.
*/
public final class BooleanDisposable : Disposable, Cancelable {

internal static let BooleanDisposableTrue = BooleanDisposable(disposed: true)
private var _disposed = false
internal static let BooleanDisposableTrue = BooleanDisposable(isDisposed: true)
private var _isDisposed = false

/**
Initializes a new instance of the `BooleanDisposable` class
Expand All @@ -25,21 +25,21 @@ public final class BooleanDisposable : Disposable, Cancelable {
/**
Initializes a new instance of the `BooleanDisposable` class with given value
*/
public init(disposed: Bool) {
self._disposed = disposed
public init(isDisposed: Bool) {
self._isDisposed = isDisposed
}

/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed
public var isDisposed: Bool {
return _isDisposed
}

/**
Sets the status to disposed, which can be observer through the `disposed` property.
Sets the status to disposed, which can be observer through the `isDisposed` property.
*/
public func dispose() {
_disposed = true
_isDisposed = true
}
}
}
2 changes: 1 addition & 1 deletion RxSwift/Disposables/CompositeDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class CompositeDisposable : DisposeBase, Disposable, Cancelable {
// state
private var _disposables: Bag<Disposable>? = Bag()

public var disposed: Bool {
public var isDisposed: Bool {
_lock.lock(); defer { _lock.unlock() }
return _disposables == nil
}
Expand Down
6 changes: 3 additions & 3 deletions RxSwift/Disposables/DisposeBag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class DisposeBag: DisposeBase {

// state
private var _disposables = [Disposable]()
private var _disposed = false
private var _isDisposed = false

/**
Constructs new empty dispose bag.
Expand Down Expand Up @@ -67,7 +67,7 @@ public final class DisposeBag: DisposeBase {

private func _insert(_ disposable: Disposable) -> Disposable? {
_lock.lock(); defer { _lock.unlock() }
if _disposed {
if _isDisposed {
return disposable
}

Expand All @@ -93,7 +93,7 @@ public final class DisposeBag: DisposeBase {
let disposables = _disposables

_disposables.removeAll(keepingCapacity: false)
_disposed = true
_isDisposed = true

return disposables
}
Expand Down
6 changes: 3 additions & 3 deletions RxSwift/Disposables/RefCountDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class RefCountDisposable : DisposeBase, Cancelable {
/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
public var isDisposed: Bool {
_lock.lock(); defer { _lock.unlock() }
return _disposable == nil
}
Expand Down Expand Up @@ -110,7 +110,7 @@ public final class RefCountDisposable : DisposeBase, Cancelable {
internal final class RefCountInnerDisposable: DisposeBase, Disposable
{
private let _parent: RefCountDisposable
private var _disposed: AtomicInt = 0
private var _isDisposed: AtomicInt = 0

init(_ parent: RefCountDisposable)
{
Expand All @@ -120,7 +120,7 @@ internal final class RefCountInnerDisposable: DisposeBase, Disposable

internal func dispose()
{
if AtomicCompareAndSwap(0, 1, &_disposed) {
if AtomicCompareAndSwap(0, 1, &_isDisposed) {
_parent.release()
}
}
Expand Down
8 changes: 4 additions & 4 deletions RxSwift/Disposables/ScheduledDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ Represents a disposable resource whose disposal invocation will be scheduled on
public final class ScheduledDisposable : Cancelable {
public let scheduler: ImmediateSchedulerType

private var _disposed: AtomicInt = 0
private var _isDisposed: AtomicInt = 0

// state
private var _disposable: Disposable?

/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed == 1
public var isDisposed: Bool {
return _isDisposed == 1
}

/**
Expand All @@ -50,7 +50,7 @@ public final class ScheduledDisposable : Cancelable {
}

func disposeInner() {
if AtomicCompareAndSwap(0, 1, &_disposed) {
if AtomicCompareAndSwap(0, 1, &_isDisposed) {
_disposable!.dispose()
_disposable = nil
}
Expand Down
14 changes: 7 additions & 7 deletions RxSwift/Disposables/SerialDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public final class SerialDisposable : DisposeBase, Cancelable {

// state
private var _current = nil as Disposable?
private var _disposed = false
private var _isDisposed = false

/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed
public var isDisposed: Bool {
return _isDisposed
}

/**
Expand All @@ -47,7 +47,7 @@ public final class SerialDisposable : DisposeBase, Cancelable {
}
set (newDisposable) {
let disposable: Disposable? = _lock.calculateLocked {
if _disposed {
if _isDisposed {
return newDisposable
}
else {
Expand All @@ -72,14 +72,14 @@ public final class SerialDisposable : DisposeBase, Cancelable {

private func _dispose() -> Disposable? {
_lock.lock(); defer { _lock.unlock() }
if _disposed {
if _isDisposed {
return nil
}
else {
_disposed = true
_isDisposed = true
let current = _current
_current = nil
return current
}
}
}
}
12 changes: 6 additions & 6 deletions RxSwift/Disposables/SingleAssignmentDisposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
private var _lock = SpinLock()

// state
private var _disposed = false
private var _isDisposed = false
private var _disposableSet = false
private var _disposable = nil as Disposable?

/**
- returns: A value that indicates whether the object is disposed.
*/
public var disposed: Bool {
return _disposed
public var isDisposed: Bool {
return _isDisposed
}

/**
Expand Down Expand Up @@ -58,7 +58,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {

_disposableSet = true

if _disposed {
if _isDisposed {
return newValue
}

Expand All @@ -71,7 +71,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
Disposes the underlying disposable.
*/
public func dispose() {
if _disposed {
if _isDisposed {
return
}
_dispose()?.dispose()
Expand All @@ -80,7 +80,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
private func _dispose() -> Disposable? {
_lock.lock(); defer { _lock.unlock() }

_disposed = true
_isDisposed = true
let disposable = _disposable
_disposable = nil

Expand Down
2 changes: 1 addition & 1 deletion RxSwift/Observables/Implementations/Buffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class BufferTimeCountSink<Element, O: ObserverType where O.E == [Element]>
}

func createTimer(_ windowID: Int) {
if _timerD.disposed {
if _timerD.isDisposed {
return
}

Expand Down
Loading

0 comments on commit f1b4e0f

Please sign in to comment.