Class/Object

fm.lazyseq

LazySeqBuilder

Related Docs: object LazySeqBuilder | package lazyseq

Permalink

final class LazySeqBuilder[A] extends Builder[A, LazySeq[A]] with Closeable with Logging

A LazySeq producer/consumer pair that uses a BlockingQueue

I think this is Thread-Safe

2021-02-19 - This was updated to allow passing in an arbitrary BlockingQueue implementation (e.g. an LMDBBlockingDeque for using an off-heap disk-backed queue). I removed the END_OF_QUEUE marker so that the BlockingQueue could be typed as a BlockingQueue[A] instead of an BlockingQueue[AnyRef] to make serialization in LMDBBlockingDeque work better.

It looks like there is a lot of cleanup potential in this class. After some original threading problems around handling exceptions in the Producer and Consumer threads it looks like I went a little overboard on error handling. There is probably room for a lot of simplification.

Self Type
LazySeqBuilder[A]
Linear Supertypes
Logging, Closeable, AutoCloseable, Builder[A, LazySeq[A]], Growable[A], Clearable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. LazySeqBuilder
  2. Logging
  3. Closeable
  4. AutoCloseable
  5. Builder
  6. Growable
  7. Clearable
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new LazySeqBuilder()

    Permalink
  2. new LazySeqBuilder(queueSize: Int)

    Permalink
  3. new LazySeqBuilder(queueSize: Int, shutdownJVMOnUncaughtException: Boolean)

    Permalink
  4. new LazySeqBuilder(queue: BlockingQueue[A], shutdownJVMOnUncaughtException: Boolean = false)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ++=(xs: TraversableOnce[A]): LazySeqBuilder.this.type

    Permalink
    Definition Classes
    Growable
  4. def +=(v: A): LazySeqBuilder.this.type

    Permalink
    Definition Classes
    LazySeqBuilder → Builder → Growable
  5. def +=(elem1: A, elem2: A, elems: A*): LazySeqBuilder.this.type

    Permalink
    Definition Classes
    Growable
  6. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  7. def abort(): Unit

    Permalink

    This will abort both the producer and consumer possibly removing items from the queue to make room for our END_OF_QUEUE marker.

  8. def abortConsumer(): Unit

    Permalink
  9. def abortProducer(): Unit

    Permalink
  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. def await(): Unit

    Permalink

    Wait for both the producer and consumer threads (if any) to finish

  12. def awaitConsumer(): Unit

    Permalink

    Wait for the consumer thread (if any) to finish

  13. def awaitProducer(): Unit

    Permalink

    Wait for the producer thread (if any) to finish

  14. def clear(): Unit

    Permalink
    Definition Classes
    LazySeqBuilder → Builder → Growable → Clearable
  15. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  16. def close(): Unit

    Permalink

    Note: It's not clear what the correct behavior of this method is.

    Note: It's not clear what the correct behavior of this method is. It will currently block until the producer/consumer threads have cleanly finished.

    Definition Classes
    LazySeqBuilder → Closeable → AutoCloseable
  17. def closeConsumer(): Unit

    Permalink
  18. def closeProducer(): Unit

    Permalink
  19. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  21. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  24. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  25. final def isProducerOrConsumerThread(): Boolean

    Permalink
    Attributes
    protected
  26. object lazySeq extends BufferedLazySeq[A] with Closeable

    Permalink
  27. lazy val logger: Logger

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  28. def mapResult[NewTo](f: (LazySeq[A]) ⇒ NewTo): Builder[A, NewTo]

    Permalink
    Definition Classes
    Builder
  29. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  30. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  32. def queueSize: Int

    Permalink
  33. def result(): LazySeq[A]

    Permalink
    Definition Classes
    LazySeqBuilder → Builder
  34. def sizeHint(coll: TraversableLike[_, _], delta: Int): Unit

    Permalink
    Definition Classes
    Builder
  35. def sizeHint(coll: TraversableLike[_, _]): Unit

    Permalink
    Definition Classes
    Builder
  36. def sizeHint(size: Int): Unit

    Permalink
    Definition Classes
    Builder
  37. def sizeHintBounded(size: Int, boundingColl: TraversableLike[_, _]): Unit

    Permalink
    Definition Classes
    Builder
  38. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  39. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  40. val uniqueId: Int

    Permalink
    Attributes
    protected
  41. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. def withConsumerThread(f: (LazySeq[A]) ⇒ Unit): LazySeqBuilder.this.type

    Permalink
  45. def withProducerThread(f: (Growable[A]) ⇒ Unit): LazySeqBuilder.this.type

    Permalink

    Run the function in a separate producer thread.

    Run the function in a separate producer thread. Should only be called once since it will close the Builder when the thread finishes.

Inherited from Logging

Inherited from Closeable

Inherited from AutoCloseable

Inherited from Builder[A, LazySeq[A]]

Inherited from Growable[A]

Inherited from Clearable

Inherited from AnyRef

Inherited from Any

Ungrouped