org.modeshape.common.collection.ring

## Class RingBufferBuilder<T,C>

- java.lang.Object
- - org.modeshape.common.collection.ring.RingBufferBuilder<T,C>

- Type Parameters:
    `T` - the type of entries stored in the buffer
    `C` - the type of consumer

      public class RingBufferBuilder<T,C>
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_BUFFER_SIZE`
    `static boolean` | `DEFAULT_GARBAGE_COLLECT_ENTITIES`
    `static String` | `DEFAULT_NAME`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `RingBufferBuilder(Executor executor, RingBuffer.ConsumerAdapter<T,C> adapter)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `RingBuffer<T,C>` | `build()`
    `protected Cursor` | `defaultCursor(int bufferSize, WaitStrategy waitStrategy)`
    `protected WaitStrategy` | `defaultWaitStrategy()`
    `RingBufferBuilder<T,C>` | `garbageCollect(boolean gcEntries)`
    `protected RingBufferBuilder<T,C>` | `multipleProducers()`
    `RingBufferBuilder<T,C>` | `named(String bufferName)`
    `RingBufferBuilder<T,C>` | `ofSize(int bufferSize)`
    `protected RingBufferBuilder<T,C>` | `singleProducer()`
    `RingBufferBuilder<T,C>` | `waitUsing(WaitStrategy waitStrategy)`
    `static <T,C extends Consumer<T>> RingBufferBuilder<T,C>` | `withMultipleProducers(Executor executor, Class<T> entryClass)` Create a builder for ring buffers that use the supplied `Executor` to create threads for each `Consumer` instance.
    `static <T,C> RingBufferBuilder<T,C>` | `withMultipleProducers(Executor executor, RingBuffer.ConsumerAdapter<T,C> adapter)` Create a builder for ring buffers that use the supplied `Executor` to create consumer threads and the supplied `RingBuffer.ConsumerAdapter` to adapt to custom consumer implementations.
    `static <T,C extends Consumer<T>> RingBufferBuilder<T,C>` | `withSingleProducer(Executor executor, Class<T> entryClass)` Create a builder for ring buffers that use the supplied `Executor` to create threads for each `Consumer` instance.
    `static <T,C> RingBufferBuilder<T,C>` | `withSingleProducer(Executor executor, RingBuffer.ConsumerAdapter<T,C> adapter)` Create a builder for ring buffers that use the supplied `Executor` to create consumer threads and the supplied `RingBuffer.ConsumerAdapter` to adapt to custom consumer implementations.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_BUFFER_SIZE

          public static final int DEFAULT_BUFFER_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_GARBAGE_COLLECT_ENTITIES

          public static final boolean DEFAULT_GARBAGE_COLLECT_ENTITIES

      See Also:
        Constant Field Values

    - #### DEFAULT_NAME

          public static final String DEFAULT_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### RingBufferBuilder

          protected RingBufferBuilder(Executor executor,
                           RingBuffer.ConsumerAdapter<T,C> adapter)

      Parameters:
        `executor` - the executor that should be used to create threads to run `Consumer`s; may not be null
        `adapter` - the adapter for consumers; may not be null

  - ### Method Detail

    - #### withSingleProducer

          public static <T,C> RingBufferBuilder<T,C> withSingleProducer(Executor executor,
                                                        RingBuffer.ConsumerAdapter<T,C> adapter)

      Create a builder for ring buffers that use the supplied `Executor` to create consumer threads and the supplied `RingBuffer.ConsumerAdapter` to adapt to custom consumer implementations. The ring buffer will only allow entries to be added from a single thread.
      Parameters:
        `executor` - the executor that should be used to create threads to run `Consumer`s; may not be null
        `adapter` - the adapter to the desired consumer interface; may not be null
      Returns:
        the builder for ring buffers; never null

    - #### withSingleProducer

          public static <T,C extends Consumer<T>> RingBufferBuilder<T,C> withSingleProducer(Executor executor,
                                                                            Class<T> entryClass)

      Create a builder for ring buffers that use the supplied `Executor` to create threads for each `Consumer` instance. The ring buffer will only allow entries to be added from a single thread.
      Parameters:
        `executor` - the executor that should be used to create threads to run `Consumer`s; may not be null
        `entryClass` - the type of entry that will be put into and consumed from the buffer; may not be null
      Returns:
        the builder for ring buffers; never null

    - #### withMultipleProducers

          public static <T,C> RingBufferBuilder<T,C> withMultipleProducers(Executor executor,
                                                           RingBuffer.ConsumerAdapter<T,C> adapter)

      Create a builder for ring buffers that use the supplied `Executor` to create consumer threads and the supplied `RingBuffer.ConsumerAdapter` to adapt to custom consumer implementations. The ring buffer will allow entries to be added from multiple threads.
      Parameters:
        `executor` - the executor that should be used to create threads to run `Consumer`s; may not be null
        `adapter` - the adapter to the desired consumer interface; may not be null
      Returns:
        the builder for ring buffers; never null

    - #### withMultipleProducers

          public static <T,C extends Consumer<T>> RingBufferBuilder<T,C> withMultipleProducers(Executor executor,
                                                                               Class<T> entryClass)

      Create a builder for ring buffers that use the supplied `Executor` to create threads for each `Consumer` instance. The ring buffer will allow entries to be added from multiple threads.
      Parameters:
        `executor` - the executor that should be used to create threads to run `Consumer`s; may not be null
        `entryClass` - the type of entry that will be put into and consumed from the buffer; may not be null
      Returns:
        the builder for ring buffers; never null

    - #### ofSize

          public RingBufferBuilder<T,C> ofSize(int bufferSize)

    - #### garbageCollect

          public RingBufferBuilder<T,C> garbageCollect(boolean gcEntries)

    - #### waitUsing

          public RingBufferBuilder<T,C> waitUsing(WaitStrategy waitStrategy)

    - #### singleProducer

          protected RingBufferBuilder<T,C> singleProducer()

    - #### multipleProducers

          protected RingBufferBuilder<T,C> multipleProducers()

    - #### named

          public RingBufferBuilder<T,C> named(String bufferName)

    - #### build

          public RingBuffer<T,C> build()

    - #### defaultWaitStrategy

          protected WaitStrategy defaultWaitStrategy()

    - #### defaultCursor

          protected Cursor defaultCursor(int bufferSize,
                             WaitStrategy waitStrategy)

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.