Java Code Examples for reactor.core.Fuseable#NONE

The following examples show how to use reactor.core.Fuseable#NONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactorClientStreamObserverAndPublisher.java    From reactive-grpc with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
    if ((requestedMode & Fuseable.ASYNC) != 0) {
        outputFused = true;
        return Fuseable.ASYNC;
    }
    return Fuseable.NONE;
}
 
Example 2
Source File: FluxWindowPredicate.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
	if ((requestedMode & Fuseable.ASYNC) != 0) {
		enableOperatorFusion = true;
		return Fuseable.ASYNC;
	}
	return Fuseable.NONE;
}
 
Example 3
Source File: FluxWindowPredicate.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
	if ((requestedMode & Fuseable.ASYNC) != 0) {
		outputFused = true;
		return Fuseable.ASYNC;
	}
	return Fuseable.NONE;
}
 
Example 4
Source File: FluxGenerate.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
	if ((requestedMode & Fuseable.SYNC) != 0 && (requestedMode & Fuseable.THREAD_BARRIER) == 0) {
		outputFused = true;
		return Fuseable.SYNC;
	}
	return Fuseable.NONE;
}
 
Example 5
Source File: AssertSubscriber.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
protected final String fusionModeName(int mode) {
	switch (mode) {
		case -1:
			return "Disabled";
		case Fuseable.NONE:
			return "None";
		case Fuseable.SYNC:
			return "Sync";
		case Fuseable.ASYNC:
			return "Async";
		default:
			return "Unknown(" + mode + ")";
	}
}
 
Example 6
Source File: FluxElapsed.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
	QueueSubscription<T> qs = Operators.as(s);
	if (qs != null) {
		this.qs = qs;
		return qs.requestFusion(requestedMode);
	}
	return Fuseable.NONE;
}
 
Example 7
Source File: AssertSubscriber.java    From RHub with Apache License 2.0 5 votes vote down vote up
protected final String fusionModeName(int mode) {
    switch (mode) {
        case -1:
            return "Disabled";
        case Fuseable.NONE:
            return "None";
        case Fuseable.SYNC:
            return "Sync";
        case Fuseable.ASYNC:
            return "Async";
        default:
            return "Unknown(" + mode + ")";
    }
}
 
Example 8
Source File: FluxPeekFuseable.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
	int m;
	if ((requestedMode & Fuseable.THREAD_BARRIER) != 0) {
		return Fuseable.NONE;
	}
	else {
		m = s.requestFusion(requestedMode);
	}
	sourceMode = m;
	return m;
}
 
Example 9
Source File: FluxDoFinally.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int mode) {
	QueueSubscription<T> qs = this.qs;
	if (qs != null && (mode & Fuseable.THREAD_BARRIER) == 0) {
		int m = qs.requestFusion(mode);
		if (m != Fuseable.NONE) {
			syncFused = m == Fuseable.SYNC;
		}
		return m;
	}
	return Fuseable.NONE;
}
 
Example 10
Source File: AssertSubscriber.java    From rsocket-java with Apache License 2.0 5 votes vote down vote up
protected final String fusionModeName(int mode) {
  switch (mode) {
    case -1:
      return "Disabled";
    case Fuseable.NONE:
      return "None";
    case Fuseable.SYNC:
      return "Sync";
    case Fuseable.ASYNC:
      return "Async";
    default:
      return "Unknown(" + mode + ")";
  }
}
 
Example 11
Source File: ReactorSubscriberAndServerProducer.java    From reactive-grpc with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected Subscription fuse(Subscription s) {
    if (s instanceof Fuseable.QueueSubscription) {
        @SuppressWarnings("unchecked")
        Fuseable.QueueSubscription<T> f = (Fuseable.QueueSubscription<T>) s;

        int m = f.requestFusion(Fuseable.ANY);

        if (m != Fuseable.NONE) {
            return new FusionAwareQueueSubscriptionAdapter<T>(f, m);
        }
    }

    return s;
}
 
Example 12
Source File: FluxMetricsFuseable.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int mode) {
	//Simply negotiate the fusion by delegating:
	if (qs != null) {
		this.mode = qs.requestFusion(mode);
		return this.mode;
	}
	return Fuseable.NONE; //should not happen unless requestFusion called before subscribe
}
 
Example 13
Source File: FluxIndexFuseable.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
	int m;
	if (indexMapper != Flux.TUPLE2_BIFUNCTION && (requestedMode & Fuseable.THREAD_BARRIER) != 0) {
		return Fuseable.NONE;
	}
	else {
		m = s.requestFusion(requestedMode);
	}
	sourceMode = m;
	return m;
}
 
Example 14
Source File: MetricsFuseableSubscriber.java    From rsocket-rpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
  int m;
  if ((requestedMode & Fuseable.THREAD_BARRIER) != 0) {
    return Fuseable.NONE;
  } else {
    m = s.requestFusion(requestedMode);
  }
  sourceMode = m;
  return m;
}
 
Example 15
Source File: FluxFilterFuseable.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
	int m;
	if ((requestedMode & Fuseable.THREAD_BARRIER) != 0) {
		return Fuseable.NONE;
	}
	else {
		m = s.requestFusion(requestedMode);
	}
	sourceMode = m;
	return m;
}
 
Example 16
Source File: MetricsFuseableSubscriber.java    From rsocket-rpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
  int m;
  if ((requestedMode & Fuseable.THREAD_BARRIER) != 0) {
    return Fuseable.NONE;
  } else {
    m = s.requestFusion(requestedMode);
  }
  sourceMode = m;
  return m;
}
 
Example 17
Source File: AssertSubscriber.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
/**
 * Assert that the fusion mode was granted.
 *
 * @return this
 */
public final AssertSubscriber<T> assertFusionRejected() {
	if (establishedFusionMode != Fuseable.NONE) {
		throw new AssertionError("Fusion was granted");
	}
	return this;
}
 
Example 18
Source File: SpanSubscription.java    From rsocket-rpc-java with Apache License 2.0 4 votes vote down vote up
@Override
default int requestFusion(int i) {
  return Fuseable.NONE; // always negotiate to no fusion
}
 
Example 19
Source File: SpanSubscription.java    From rsocket-rpc-java with Apache License 2.0 4 votes vote down vote up
@Override
default int requestFusion(int i) {
  return Fuseable.NONE; // always negotiate to no fusion
}
 
Example 20
Source File: DefaultStepVerifierBuilder.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
final void startFusion(Subscription s) {
	if (s instanceof Fuseable.QueueSubscription) {
		@SuppressWarnings("unchecked") Fuseable.QueueSubscription<T> qs =
				(Fuseable.QueueSubscription<T>) s;

		this.qs = qs;

		int m = qs.requestFusion(requestedFusionMode);
		if (expectedFusionMode == Fuseable.NONE && m != Fuseable.NONE) {
			setFailure(null,
					"expected no fusion; actual: %s",
					formatFusionMode(m));
			return;
		}
		if (expectedFusionMode != Fuseable.NONE && m == Fuseable.NONE) {
			setFailure(null,
					"expected fusion: %s; actual does not support " + "fusion",
					formatFusionMode(expectedFusionMode));
			return;
		}
		if ((m & expectedFusionMode) != m) {
			setFailure(null, "expected fusion mode: %s; actual: %s",
					formatFusionMode(expectedFusionMode),
					formatFusionMode(m));
			return;
		}

		this.establishedFusionMode = m;

		if (m == Fuseable.SYNC) {
			T v;
			for (; ; ) {
				if(get() == Operators.cancelledSubscription()){
					return;
				}
				try {
					v = qs.poll();
				}
				catch (Throwable e) {
					Exceptions.throwIfFatal(e);
					cancel();
					onError(Exceptions.unwrap(e));
					return;
				}
				if (v == null) {
					onComplete();
					break;
				}

				onNext(v);
			}
		}
		else if (initialRequest != 0) {
			s.request(initialRequest);
		}
	}
	else if (expectedFusionMode != Fuseable.NONE) {
		setFailure(null,
				"expected fuseable source but actual Subscription " + "is " +
						"not: %s",
				expectedFusionMode,
				s);
	}
	else if (initialRequest != 0L) {
		s.request(initialRequest);
	}
}