Giter Site home page Giter Site logo

Comments (6)

jspahrsummers avatar jspahrsummers commented on March 29, 2024

I'm pretty sure this is captured by #138, since if those methods send nexts/error/completed to a serialized id<RACSubscriber>, it should work even if the original signals deliver on different threads.

from reactivecocoa.

Coneko avatar Coneko commented on March 29, 2024

Not if the implementation uses a different subscriber for each signal, which is what most of these methods do.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on March 29, 2024

I'm not sure I follow. Could you create a small example?

from reactivecocoa.

Coneko avatar Coneko commented on March 29, 2024

Hard to have a test case for it, but if you look at +combineLatest:reduce::

for(id<RACSignal> signal in signals) {

New RACSubscriber created for each signal

  RACDisposable *disposable = [signal subscribe:[RACSubscriber subscriberWithNext:^(id x) {

nexts are synchronized on lastValues

    @synchronized(lastValues) {
      [lastValues setObject:x ? : [RACTupleNil tupleNil] forKey:[NSString stringWithFormat:@"%p", signal]];

      if(lastValues.count == signals.count) {
        NSMutableArray *orderedValues = [NSMutableArray arrayWithCapacity:signals.count];
        for(id<RACSignal> o in signals) {
          [orderedValues addObject:[lastValues objectForKey:[NSString stringWithFormat:@"%p", o]]];
        }

        if (reduceBlock == NULL) {
          [subscriber sendNext:[RACTuple tupleWithObjectsFromArray:orderedValues]];
        } else {
          [subscriber sendNext:[RACBlockTrampoline invokeBlock:reduceBlock withArguments:orderedValues]];
        }
      }
    }
  } error:^(NSError *error) {

errors aren't synchronized

    [subscriber sendError:error];
  } completed:^{

completeds are synchronized on completedSignals

    @synchronized(completedSignals) {
      [completedSignals addObject:signal];
      if(completedSignals.count == signals.count) {
        [subscriber sendCompleted];
      }
    }
  }]];

  if(disposable != nil) {
    [disposables addObject:disposable];
  }
}

Since next, error and completed are delivered to different RACSubscribers, and are synchronized on different locks, subscriber could get deliveries from different threads concurrently.

from reactivecocoa.

jspahrsummers avatar jspahrsummers commented on March 29, 2024

I can understand why the synchronization might result in delays, but subscriber – the ultimate subscriber that each intermediate one delivers to – could still serialize the messages it receives, which would solve the thrust of this issue.

from reactivecocoa.

Coneko avatar Coneko commented on March 29, 2024

Oh you're right, my bad.
Does this mean #136 is 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.

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.