Class

com.fulcrumgenomics.commons.async

AsyncWriterPool

Related Doc: package async

Permalink

class AsyncWriterPool extends Closeable

A shared thread pool for making asynchronous Writers without allocating a thread per writer. The pool is created with a fixed number of threads which are used to handle write operations for all writers associated to the pool.

Writers are added to the pool using the pool() method, which returns a PooledWriter that can be written to in place of the original Writer. Writers of different types can be mixed within the same pool, and each writer can specify either an unbounded queue or a fixed queue of independent size when being pooled.

Writer can be added to the pool at any time (except aftering calling close() on the pool. Writers can be closed individually (and removed from the pool) using either their PooledWriter.close() method which runs synchronously on the calling thread, or by using PooledWriter.closeAsync() which will execute the close asynchronously and return a Future upon which get() must be called to re-throw any exceptions that were thrown during the close operation.

The entire pool can be closed be calling close() on the pool. This will asynchronously close all open writers, shutdown the internal thread pool, and rethrow the first exception (if any) encountered when closing writers.

Linear Supertypes
Closeable, AutoCloseable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AsyncWriterPool
  2. Closeable
  3. AutoCloseable
  4. AnyRef
  5. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new AsyncWriterPool(threads: Int)

    Permalink

    threads

    the number of threads to use to write items.

Type Members

  1. class PooledWriter[A] extends Writer[A]

    Permalink

    Wraps a Writer[A] in the context of an AsyncWriterPool to provide asynchronous operations.

    Wraps a Writer[A] in the context of an AsyncWriterPool to provide asynchronous operations. Calls to write() and related methods place items into the queue, and if necessary, schedule the queue for draining using the executor in the enclosing AsyncWriterPool.

Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from AsyncWriterPool to any2stringadd[AsyncWriterPool] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (AsyncWriterPool, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from AsyncWriterPool to ArrowAssoc[AsyncWriterPool] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

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

    Permalink

    Closes the pool and all writers currently within the pool.

    Closes the pool and all writers currently within the pool. If any writer throws an exception during close() then an exception will be thrown from this method. Only the first encountered exception is thrown.

    Definition Classes
    AsyncWriterPool → Closeable → AutoCloseable
  9. def ensuring(cond: (AsyncWriterPool) ⇒ Boolean, msg: ⇒ Any): AsyncWriterPool

    Permalink
    Implicit information
    This member is added by an implicit conversion from AsyncWriterPool to Ensuring[AsyncWriterPool] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: (AsyncWriterPool) ⇒ Boolean): AsyncWriterPool

    Permalink
    Implicit information
    This member is added by an implicit conversion from AsyncWriterPool to Ensuring[AsyncWriterPool] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean, msg: ⇒ Any): AsyncWriterPool

    Permalink
    Implicit information
    This member is added by an implicit conversion from AsyncWriterPool to Ensuring[AsyncWriterPool] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean): AsyncWriterPool

    Permalink
    Implicit information
    This member is added by an implicit conversion from AsyncWriterPool to Ensuring[AsyncWriterPool] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. final def eq(arg0: AnyRef): Boolean

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from AsyncWriterPool to StringFormat[AsyncWriterPool] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  17. final def getClass(): Class[_]

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
  23. def pool[A](writer: Writer[A], queueSize: Option[Int] = None): PooledWriter[A]

    Permalink

    Takes a Writer and wraps it into a PooledWriter.

    Takes a Writer and wraps it into a PooledWriter. The input Writer should not be accessed directly after this call. The returned PooledWriter can be written to in a manner identical to the original writer.

    PooledWriters can used either an unbounded queue for storing to-be-written items (with queueSize=None) or a fixed queue of a given size (with queueSize=Some(n)). If a fixed size queue is written it is possible for write methods on PooledWriter to block if the queue is full, until some items are removed and written.

    A

    the type of items written to the writer

    writer

    the writer to be wrapped and made asynchronous

    queueSize

    an optional queue size for the writer

    returns

    a pooled writer that will perform writing asynchronously

  24. final def synchronized[T0](arg0: ⇒ T0): T0

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

    Permalink
    Definition Classes
    AnyRef → Any
  26. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. def [B](y: B): (AsyncWriterPool, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from AsyncWriterPool to ArrowAssoc[AsyncWriterPool] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from Closeable

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from AsyncWriterPool to any2stringadd[AsyncWriterPool]

Inherited by implicit conversion StringFormat from AsyncWriterPool to StringFormat[AsyncWriterPool]

Inherited by implicit conversion Ensuring from AsyncWriterPool to Ensuring[AsyncWriterPool]

Inherited by implicit conversion ArrowAssoc from AsyncWriterPool to ArrowAssoc[AsyncWriterPool]

Ungrouped