Giter Site home page Giter Site logo

Comments (5)

mdiep avatar mdiep commented on June 18, 2024

I don't fully understand this part of the code yet, but .interrupted can propagate up the signal chain when something is disposed or interrupted.

from reactiveswift.

andersio avatar andersio commented on June 18, 2024

A started SignalProducer is allowed to be interrupted in the observer it is started with. Since we serialise events using sendLock, such use would deadlock unless it is treated specially (and it is).

from reactiveswift.

kAzec avatar kAzec commented on June 18, 2024

Oh, thanks, now I see.

from reactiveswift.

andersio avatar andersio commented on June 18, 2024

A code snippet to illustrate this if you are interested.

let (signal, observer) = Signal<Int, NoError>.pipe()
var disposable: Disposable?

disposable = SignalProducer<Int, NoError>(signal: signal)
    .startWithValues { _ in
        print(disposable)
        disposable?.dispose()
    }

observer.send(value: 1)

The value event is pushed to the produced signal, causing a disposal of the producer. Since by default everything is synchronous, if we do not treat interrupt specially, we would stuck at attempting to lock sendLock again within the critical section of sendLock (the value event).

from reactiveswift.

kAzec avatar kAzec commented on June 18, 2024

Understood. And also under the following condition which may be more common:

signalProducer
    .startWithSignal { signal, interrupter in
        signal.observe { event in
            // ...
            interrupter.dispose()
        }
    }

from reactiveswift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.