Skip to content

Commit

Permalink
[Gardening] Signal.Core.
Browse files Browse the repository at this point in the history
  • Loading branch information
andersio committed May 28, 2017
1 parent 5d5e983 commit a23ef34
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions Sources/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,21 @@ public final class Signal<Value, Error: Swift.Error> {
/// `Signal` ownership graph from the perspective of an operator.
/// Note that there is no circular strong reference in the graph.
/// ```
/// ------------ -------------- --------
/// | | | endObserve | | |
/// | | <~~ weak ~~~ | disposable | <== strong === | |
/// | | -------------- | | ... downstream(s)
/// | | ------------ | |
/// | upstream | === strong ==> | Observer | === strong ==> | Core |
/// ------------ ------------ --------
/// ------------------ ^^
/// | Signal (shell) | === strong ==//
/// ------------------
/// ------------ -------------- --------
/// | | | endObserve | | |
/// | | <~~ weak ~~~ | disposable | <== strong === | |
/// | | -------------- | | ... downstream(s)
/// | Upstream | ------------ | |
/// | Core | === strong ==> | Observer | === strong ==> | Core |
/// ------------ ===\\ ------------ -------- ===\\
/// \\ ------------------ ^^ \\
/// \\ | Signal (shell) | === strong ==// \\
/// \\ ------------------ \\
/// || strong || strong
/// vv vv
/// ------------------- -------------------
/// | Other observers | | Other observers |
/// ------------------- -------------------
/// ```
private let core: Core

Expand Down Expand Up @@ -327,8 +332,8 @@ public final class Signal<Value, Error: Swift.Error> {
return commit()
}

/// Try to dispose of the signal silently if the `Signal` has deinitialized and has
/// no observer.
/// Try to dispose of the signal silently if the `Signal` has deinitialized and
/// has no observer.
///
/// It fails gracefully if the signal is terminating or terminated, has one or
/// more observers, or has not deinitialized.
Expand Down Expand Up @@ -358,11 +363,11 @@ public final class Signal<Value, Error: Swift.Error> {
return .none
}

/// Acknowledge the deinitialization of the shell.
fileprivate func shellDidDeinitialize() {
/// Acknowledge the deinitialization of the `Signal`.
fileprivate func signalDidDeinitialize() {
updateLock.lock()

// Mark the `Signal` shell has now deinitialized.
// Mark the `Signal` has now deinitialized.
hasDeinitialized = true

// Attempt to start the disposal of the signal if it has no active observer.
Expand Down Expand Up @@ -414,7 +419,7 @@ public final class Signal<Value, Error: Swift.Error> {
}

deinit {
core.shellDidDeinitialize()
core.signalDidDeinitialize()
}

/// The state of a `Signal`.
Expand Down

0 comments on commit a23ef34

Please sign in to comment.