GithubHelp home page GithubHelp logo

Comments (6)

andersio avatar andersio commented on April 28, 2024 1

Tried to prototype it and it wasn't quite ideal. The creation and the retrieval of the RAC internal serial queue need extra synchronisation that adds overhead on every scheduling attempt.

from reactiveswift.

NachoSoto avatar NachoSoto commented on April 28, 2024

Serial execution is importan though. I don't remember the exact context, but RAC 2 had many problems as a consequence of that.

from reactiveswift.

mdiep avatar mdiep commented on April 28, 2024

I think we also need to start limiting changes for ReactiveSwift 1.0.

from reactiveswift.

andersio avatar andersio commented on April 28, 2024

@NachoSoto It seems RACScheduler had once allowed concurrent execution, but no longer did. That's said we can still accomplish a similar semantic by creating an internal serial queue that targets any arbitrary queue supplied.

from reactiveswift.

robertjpayne avatar robertjpayne commented on April 28, 2024

EDIT: Ignore me, this is a pretty bad implementation. It's much easier to implement SchedulerProtocol for simple backgrounding via start(on:)

@NachoSoto do you have any more info about why QueueScheduler's need to be serial? I quite frequently have "background" tasks and I just found out that a single QueueScheduler prevents any sort of concurrent execution.

I'm working around this right now by creating a pool of QueueScheduler's and round robin the operators onto them.

It just seems less than ideal…

extension QueueScheduler {
    static var concurrent: QueueScheduler {
        // a single QueueScheduler enforces serial FIFO execution of scheduled blocks. To allow for concurrent execution
        // we instead use a pool of QueueSchedulers and rotate them as they are accessed
        return self.concurrentSchedulers.modify { schedulers in
            let scheduler = schedulers.removeFirst()
            schedulers.append(scheduler)
            return scheduler
        }
    }
    
    private static var concurrentSchedulers = Atomic<[QueueScheduler]>([
        QueueScheduler(qos: .default, name: "concurrent"),
        QueueScheduler(qos: .default, name: "concurrent"),
        QueueScheduler(qos: .default, name: "concurrent"),
        QueueScheduler(qos: .default, name: "concurrent"),
        QueueScheduler(qos: .default, name: "concurrent"),
        QueueScheduler(qos: .default, name: "concurrent"),
        QueueScheduler(qos: .default, name: "concurrent"),
        QueueScheduler(qos: .default, name: "concurrent")
    ])
}

from reactiveswift.

andersio avatar andersio commented on April 28, 2024

signal.observe(on: ConcurrentScheduler()) would result in a Signal which delivers values in indeterministic order. But it would be an intentional use of concurrent queues, and other than this I was not aware of any context in ReactiveSwift which might oppose such use.

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.