Search in sources :

Example 1 with ConcurrentSubscription

use of io.servicetalk.concurrent.internal.ConcurrentSubscription in project servicetalk by apple.

the class WriteStreamSubscriber method onSubscribe.

@Override
public void onSubscribe(Subscription s) {
    final Subscription concurrentSubscription = ConcurrentSubscription.wrap(s);
    if (!subscriptionUpdater.compareAndSet(this, null, concurrentSubscription)) {
        // Either onSubscribe was called twice or Subscription is cancelled, in both cases, we cancel the new
        // Subscription.
        s.cancel();
        return;
    }
    subscriber.onSubscribe(concurrentSubscription);
    if (eventLoop.inEventLoop()) {
        initialRequestN(concurrentSubscription);
    } else {
        eventLoop.execute(() -> initialRequestN(concurrentSubscription));
    }
}
Also used : ConcurrentSubscription(io.servicetalk.concurrent.internal.ConcurrentSubscription) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) EmptySubscriptions.newEmptySubscription(io.servicetalk.concurrent.internal.EmptySubscriptions.newEmptySubscription)

Aggregations

Subscription (io.servicetalk.concurrent.PublisherSource.Subscription)1 ConcurrentSubscription (io.servicetalk.concurrent.internal.ConcurrentSubscription)1 EmptySubscriptions.newEmptySubscription (io.servicetalk.concurrent.internal.EmptySubscriptions.newEmptySubscription)1