Class/Object

com.fulcrumgenomics.commons.async

AsyncSink

Related Docs: object AsyncSink | package async

Permalink

class AsyncSink[T] extends Closeable with AsyncRunnable

Asynchronous wrapper for applying a sink method to items of type [T]. Items can be added to this sink (with add()) until no more items will be added (indicated by calling the close() method), ensuring all items added to the sink will have the sink method applied to them.

NOTE: Any exception thrown by the sink method will be propagated back to the caller during the next available call to add() or close(). After the exception has been thrown to the caller, it is not safe to attempt further operations on the instance.

NOTE: add() or close() are not thread-safe, so there must be only one thread that calls them.

T

the type of object to process

Linear Supertypes
AsyncRunnable, Runnable, Closeable, AutoCloseable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AsyncSink
  2. AsyncRunnable
  3. Runnable
  4. Closeable
  5. AutoCloseable
  6. AnyRef
  7. 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 AsyncSink(sink: (T) ⇒ Unit, bufferSize: Option[Int] = None, source: Option[AnyRef { def close(): Unit }] = None)

    Permalink

    sink

    the method to invoke to process an object of type T.

    bufferSize

    the number of elements to buffer before blocking when processing the elements, or None if unbounded.

    source

    the optional source to close when this sink is closed.

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 AsyncSink[T] to any2stringadd[AsyncSink[T]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (AsyncSink[T], B)

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

    Permalink
    Definition Classes
    AnyRef → Any
  6. def add(item: T): Unit

    Permalink

    Adds the item to the queue to be processed by sink.

    Adds the item to the queue to be processed by sink.

    item

    the item to queue

  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def awaitDone(): Unit

    Permalink

    Waits for the run() method to complete.

    Waits for the run() method to complete.

    Definition Classes
    AsyncRunnable
  9. def awaitStart(): Unit

    Permalink

    Waits for the run() method to start.

    Waits for the run() method to start.

    Definition Classes
    AsyncRunnable
  10. final def checkAndRaise(): Unit

    Permalink

    Checks to see if an exception has been raised by an asynchronous thread and if so rethrows it.

    Checks to see if an exception has been raised by an asynchronous thread and if so rethrows it. Use this method before code that assumes the threads have not encountered an exception.

    Attributes
    protected
    Definition Classes
    AsyncRunnable
  11. def clone(): AnyRef

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

    Permalink

    Attempts to finish draining the queue and then calls close() on the source to allow implementation to do any one time clean up.

    Attempts to finish draining the queue and then calls close() on the source to allow implementation to do any one time clean up.

    Definition Classes
    AsyncSink → Closeable → AutoCloseable
  13. def done: Boolean

    Permalink

    Returns true if the run() method has completed, false otherwise.

    Returns true if the run() method has completed, false otherwise.

    Definition Classes
    AsyncRunnable
  14. def ensuring(cond: (AsyncSink[T]) ⇒ Boolean, msg: ⇒ Any): AsyncSink[T]

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  20. def execute(): Unit

    Permalink

    The method that does the asynchronous work.

    The method that does the asynchronous work.

    Attributes
    protected
    Definition Classes
    AsyncSinkAsyncRunnable
  21. def finalize(): Unit

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

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

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

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

    Permalink
    Definition Classes
    Any
  26. val name: String

    Permalink

    The name of this runnable.

    The name of this runnable. This is used as the name of the thread in thread() as well. The name is created based on the class name and the number of AsyncRunnables already created.

    Definition Classes
    AsyncRunnable
  27. final def ne(arg0: AnyRef): Boolean

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

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

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

    Permalink
    Definition Classes
    AsyncRunnable → Runnable
  31. val sink: (T) ⇒ Unit

    Permalink

    the method to invoke to process an object of type T.

  32. val source: Option[AnyRef { def close(): Unit }]

    Permalink

    the optional source to close when this sink is closed.

  33. final def start(name: Option[String] = None, daemon: Boolean = true): AsyncSink.this.type

    Permalink

    Starts this Runnable in a daemon thread.

    Starts this Runnable in a daemon thread.

    name

    optionally the name of the thread, otherwise a name is created based on the class name and the number of threads already created.

    Definition Classes
    AsyncRunnable
  34. def started: Boolean

    Permalink

    Returns true if the run() method has started, false otherwise.

    Returns true if the run() method has started, false otherwise.

    Definition Classes
    AsyncRunnable
  35. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  36. final def thread(): Thread

    Permalink

    Creates a new thread wrapping this runnable; the thread is not started.

    Creates a new thread wrapping this runnable; the thread is not started.

    Definition Classes
    AsyncRunnable
  37. def throwable: Option[Throwable]

    Permalink

    Returns a throwable if an exception occurred in the run() method, None otherwise.

    Returns a throwable if an exception occurred in the run() method, None otherwise.

    Definition Classes
    AsyncRunnable
  38. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  39. def tryAndModifyInterruptedException[T](message: String)(f: ⇒ T): T

    Permalink

    Executes the given block of code.

    Executes the given block of code. If an InterruptedException is thrown, throws a RuntimeException with the given message. Use this method for blocking code that when interrupted should not be recoverable.

    message

    the message to use if an InterruptedException is thrown by the block of code

    f

    the block of code to execute

    Attributes
    protected
    Definition Classes
    AsyncRunnable
  40. def uponDone()(implicit ec: ExecutionContext): Awaitable[Option[Throwable]]

    Permalink

    Returns an Awaitable that completes when the run() method has completed.

    Returns an Awaitable that completes when the run() method has completed. Returns the throwable if an exception was encountered, None otherwise.

    Definition Classes
    AsyncRunnable
  41. def uponException(): Unit

    Permalink

    The method to execute if an exception occurs in the asynchronous thread.

    The method to execute if an exception occurs in the asynchronous thread. This should not block.

    Attributes
    protected
    Definition Classes
    AsyncSinkAsyncRunnable
  42. def uponFinally(): Unit

    Permalink

    The method to execute upon successfully execution of the run method or an exception occurs.

    The method to execute upon successfully execution of the run method or an exception occurs. This should not block.

    Attributes
    protected
    Definition Classes
    AsyncRunnable
  43. def uponStart()(implicit ec: ExecutionContext): Awaitable[Unit]

    Permalink

    Returns an Awaitable that completes when the run() method has started.

    Returns an Awaitable that completes when the run() method has started. Returns the throwable if an exception was encountered, None otherwise.

    Definition Classes
    AsyncRunnable
  44. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  47. def [B](y: B): (AsyncSink[T], B)

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

Inherited from AsyncRunnable

Inherited from Runnable

Inherited from Closeable

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from AsyncSink[T] to any2stringadd[AsyncSink[T]]

Inherited by implicit conversion StringFormat from AsyncSink[T] to StringFormat[AsyncSink[T]]

Inherited by implicit conversion Ensuring from AsyncSink[T] to Ensuring[AsyncSink[T]]

Inherited by implicit conversion ArrowAssoc from AsyncSink[T] to ArrowAssoc[AsyncSink[T]]

Ungrouped