Package com.gengoai.io
Class AsyncWriter
- java.lang.Object
-
- java.io.Writer
-
- com.gengoai.io.AsyncWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
,Runnable
public class AsyncWriter extends Writer implements Runnable
Wraps an underlying writer allowing multiple threads to write through buffering calls to a blocking queue.
- Author:
- David B. Bracewell
-
-
Constructor Summary
Constructors Constructor Description AsyncWriter(Writer wrap)
Creates an instance of an Asynchronous writer wrapping a given writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
boolean
isTerminated()
Determines if the writing has been terminatedvoid
run()
void
write(char[] cbuf, int off, int len)
-
-
-
Constructor Detail
-
AsyncWriter
public AsyncWriter(Writer wrap)
Creates an instance of an Asynchronous writer wrapping a given writer.- Parameters:
wrap
- The writer being wrapped
-
-
Method Detail
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
isTerminated
public boolean isTerminated()
Determines if the writing has been terminated- Returns:
- True if terminate, False if not
-
write
public void write(char[] cbuf, int off, int len) throws IOException
- Specified by:
write
in classWriter
- Throws:
IOException
-
-