public class DumperBus extends Writer
Those lines can be awaited and consumed.
This is an asynchronous blocking implementation. Different threads can write and read on this writer.
Modifier and Type | Class and Description |
---|---|
static interface |
DumperBus.Dumper
Source for dumping values to this writer.
|
Constructor and Description |
---|
DumperBus(DumperBus.Dumper source) |
DumperBus(DumperBus.Dumper source,
int capacity) |
Modifier and Type | Method and Description |
---|---|
String |
await()
Consume the queue, blocking and awaiting a new line if the queue is empty.
|
void |
close()
Called after dumping all the values.
|
void |
dump()
Dump source values into this writer in a background thread.
|
void |
flush()
Append the current characters to the queue as a new line and reset the current line buffer.
|
protected boolean |
isClosed() |
protected void |
runThread(org.simpleyaml.utils.DumperBus.Task task)
Start a new thread executing a task.
|
DumperBus.Dumper |
source()
Get the dumper source where values are read.
|
void |
write(char[] str,
int offset,
int len)
Append to line a portion of an array of characters.
|
public DumperBus(DumperBus.Dumper source, int capacity)
public DumperBus(DumperBus.Dumper source)
public void dump() throws IOException
IOException
- if I/O error occurspublic void write(char[] str, int offset, int len) throws IOException
New lines are flushed.
write
in class Writer
str
- Array of charactersoffset
- Offset from which to start writing characterslen
- Number of characters to writeIndexOutOfBoundsException
- if offset < 0
or len < 0
or offset+len > str.length
IOException
- if I/O error occurspublic void flush() throws IOException
flush
in interface Flushable
flush
in class Writer
IOException
- if I/O error occurspublic String await() throws IOException
IOException
- if I/O error occurspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
- if I/O error occursprotected boolean isClosed()
public DumperBus.Dumper source()
protected void runThread(org.simpleyaml.utils.DumperBus.Task task) throws IOException
task
- the task to runIOException
- if I/O error occursCopyright © 2023. All rights reserved.