An asynchronous wrapper for an Iterator.
A trait that can be mixed in to help manage asynchronous execution while being Runnable.
A trait that can be mixed in to help manage asynchronous execution while being Runnable.
The execute()
method should contain the work to be performed asynchronously.
The thread()
method can be used to return a Thread that wraps this Runnable.
The start()
method can be used to create and start daemon Thread that wraps this Runnable.
The checkAndRaise()
method should be used by implementing classes to check if the
execute()
method has encountered an exception, and if so, it will rethrow the exception as an
Error or RuntimeException.
The tryAndModifyInterruptedException()
method should wrap blocking code in implementing classes
that are not part of the execute()
method. This method will throw a RuntimeException if interrupted while
waiting.
Asynchronous wrapper for applying a sink
method to items of type [T].
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.
the type of object to process
An asynchronous wrapper around a Writer class.
An asynchronous wrapper around a Writer class.
the type of object to write
A shared thread pool for making asynchronous Writers without allocating a thread per writer.
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.
An asynchronous wrapper for an Iterator. A separate thread will be created to consume the source iterator. Will buffer up to bufferSize elements before the blocking when consuming the source.
the type of object to consume