GithubHelp home page GithubHelp logo

Comments (9)

Coneko avatar Coneko commented on April 17, 2024

deferredScheduler uses dispatch_get_current_queue so it probably shouldn't be used except for logging or testing purposes in the first place.

from reactivecocoa.

joshaber avatar joshaber commented on April 17, 2024

I think the lesson of this and #94 is that RACScheduler needs to become a lot more capable.

from reactivecocoa.

Coneko avatar Coneko commented on April 17, 2024

This also implies calling send on a RACSubject from different threads isn't safe if some of it's subscriptions are done indirectly through the non-threadsafe <RACSignal> methods.

I've always used RAC very conservative thread-wise, so I haven't looked into it much, but it seems to me the documentation doesn't make it very clear what is and what is not thread-safe.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 17, 2024

@Coneko That's a good point, but we can solve it by serializing RACSubject message delivery in the same way we're discussing for RACScheduler.

I definitely don't think <RACSignal> and <RACStream> methods should need explicit synchronization. They should be able to treat the stream serially.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 17, 2024

From @Coneko in #143:

[Is] #136 also covered by #138? It doesn't matter if a scheduler delivers concurrently if the subscriber which is the receiver of the delivery takes care of serializing the deliveries.

I want to say that this can be closed once #138 is implemented, but I'm worried there's something I'm overlooking. I'll think about it a bit more.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 17, 2024

Based on how I've fixed RACSubscriber's thread safety in #147, this might still be valuable. That implementation merely applies an arbitrary order to incoming concurrent messages – there's no real concept of thread FIFO.

For example:

RACSubject *subject = [RACSubject subject];

[RACScheduler.backgroundScheduler schedule:^{
    [subject sendNext:@0];
}];

[RACScheduler.backgroundScheduler schedule:^{
    [subject sendNext:@1];
}];

[RACScheduler.backgroundScheduler schedule:^{
    [subject sendNext:@2];
}];

Would you expect 0, 1, and 2 to arrive in that order? There's no guarantee that's how it'll happen right now, because each scheduled block is asynchronous on a concurrent queue, and context switching could cause a later send to complete before an earlier one.

Now, whether this is actually an issue in practice, I still don't know.

from reactivecocoa.

Coneko avatar Coneko commented on April 17, 2024

It makes sense to document this behavior in RACScheduler and let the user decide whether they'd rather have a serializing scheduler to ensure values are received in the same order they're sent in or a parallel scheduler to process values as fast as possible.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 17, 2024

πŸ‘ Fair point.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on April 17, 2024

As part of this, it'd also be nice to add a couple things to RACScheduler to solidify a serial vs. concurrent distinction:

// Whether this scheduler is concurrent.
@property (nonatomic, readonly, getter = isConcurrent) BOOL concurrent;

// Returns a serial RACScheduler that schedules its blocks on the receiver.
- (instancetype)asSerialScheduler;

from reactivecocoa.

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.