Package reactor.core

Interface Fuseable

All Known Implementing Classes:
Operators.MonoSubscriber, ReplayProcessor, UnicastProcessor

public interface Fuseable
A micro API for stream fusion, in particular marks producers that support a Fuseable.QueueSubscription.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A subscriber variant that can immediately tell if it consumed the value or not, directly allowing a new value to be sent if it didn't.
    static interface 
    Support contract for queue-fusion based optimizations on subscriptions.
    static interface 
    Marker interface indicating that the target can return a value or null, otherwise fail immediately and thus a viable target for assembly-time optimizations.
    static interface 
    Base class for synchronous sources which have fixed size and can emit their items in a pull fashion, thus avoiding the request-accounting overhead in many cases.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Indicates the QueueSubscription should decide what fusion it performs (input only).
    static final int
    Indicates the QueueSubscription can perform only async-fusion.
    static final int
    Indicates the QueueSubscription can't support the requested mode.
    static final int
    Indicates the QueueSubscription can perform sync-fusion.
    static final int
    Indicates that the queue will be drained from another thread thus any queue-exit computation may be invalid at that point.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static String
    fusionModeName(int mode)
    Attempt to convert a fusion mode int code into a human-readable representation.
    static String
    fusionModeName(int mode, boolean ignoreThreadBarrier)
    Attempt to convert a fusion mode int code into a human-readable representation.
  • Field Details

    • NONE

      static final int NONE
      Indicates the QueueSubscription can't support the requested mode.
      See Also:
    • SYNC

      static final int SYNC
      Indicates the QueueSubscription can perform sync-fusion.
      See Also:
    • ASYNC

      static final int ASYNC
      Indicates the QueueSubscription can perform only async-fusion.
      See Also:
    • ANY

      static final int ANY
      Indicates the QueueSubscription should decide what fusion it performs (input only).
      See Also:
    • THREAD_BARRIER

      static final int THREAD_BARRIER
      Indicates that the queue will be drained from another thread thus any queue-exit computation may be invalid at that point.

      For example, an asyncSource.map().publishOn().subscribe() sequence where asyncSource is async-fuseable: publishOn may fuse the whole sequence into a single Queue. That in turn could invoke the mapper function from its poll() method from another thread, whereas the unfused sequence would have invoked the mapper on the previous thread. If such mapper invocation is costly, it would escape its thread boundary this way.

      See Also:
  • Method Details

    • fusionModeName

      static String fusionModeName(int mode)
      Attempt to convert a fusion mode int code into a human-readable representation. Note that this can include the THREAD_BARRIER flag, as an appended +THREAD_BARRIER.

      This method accepts -1 as a special code, mainly for the benefit of supporting testing scenarios where fusion can be entirely deactivated (returns Disabled). Other negative values and unknown positive codes on the other hand return Unknown(x).

      Note that as this is a human-facing representation, the different values could evolve in the future. As such, never compare the returned string to a constant, but always use this method on both sides of a comparison.

      Parameters:
      mode - the fusion mode int code
      Returns:
      a human-readable String representation of the code
    • fusionModeName

      static String fusionModeName(int mode, boolean ignoreThreadBarrier)
      Attempt to convert a fusion mode int code into a human-readable representation. Note that this can include the THREAD_BARRIER flag, as an appended +THREAD_BARRIER, unless the ignoreThreadBarrier parameter is set to true.

      This method accepts -1 as a special code, mainly for the benefit of supporting testing scenarios where fusion can be entirely deactivated (returns Disabled). Other negative values and unknown positive codes on the other hand return Unknown(x).

      Note that as this is a human-facing representation, the different values could evolve in the future. As such, never compare the returned string to a constant, but always use this method on both sides of a comparison.

      Parameters:
      mode - the fusion mode int code
      ignoreThreadBarrier - whether or not to ignore the THREAD_BARRIER flag in the representation
      Returns:
      a human-readable String representation of the code