public class NioFiberImpl extends Object implements Runnable, NioFiber
Modifier and Type | Class and Description |
---|---|
static class |
NioFiberImpl.BufferedWrite<T extends SelectableChannel & WritableByteChannel> |
static class |
NioFiberImpl.NoOpBuffer |
static class |
NioFiberImpl.NoOpWriteFailure |
static interface |
NioFiberImpl.OnBuffer |
static interface |
NioFiberImpl.WriteFailure |
Constructor and Description |
---|
NioFiberImpl() |
NioFiberImpl(NioBatchExecutor executor,
Collection<NioChannelHandler> handlers) |
NioFiberImpl(NioBatchExecutor executor,
Collection<NioChannelHandler> nioHandlers,
String threadName,
boolean isDaemonThread,
NioFiberImpl.WriteFailure writeFailed,
NioFiberImpl.OnBuffer onBuffer) |
Modifier and Type | Method and Description |
---|---|
void |
add(Disposable disposable)
Add a
Disposable to be disposed when this component is disposed |
void |
addHandler(NioChannelHandler handler) |
static ByteBuffer |
addTo(ByteBuffer data,
ByteBuffer buffer) |
void |
dispose()
Dispose this instance.
|
void |
execute(Callback<NioControls> asyncWrite) |
void |
execute(Runnable command) |
Thread |
getThread() |
boolean |
remove(Disposable disposable)
Remove a
Disposable from being disposed when this component is disposed |
void |
run() |
Disposable |
schedule(Runnable command,
long delay,
TimeUnit unit)
Creates and executes a one-shot action that becomes enabled after the given delay.
|
Disposable |
scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after the given initial delay,
and subsequently with the given period; that is executions will commence after initialDelay
then initialDelay+period, then initialDelay + 2 * period, and so on.
|
Disposable |
scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit)
Creates and executes a periodic action that becomes enabled first
after the given initial delay, and subsequently with the
given delay between the termination of one execution and the
commencement of the next.
|
int |
size()
Return the number of
Disposable instances registered with this instance. |
void |
start()
Start consuming events
|
static void |
writeAll(WritableByteChannel channel,
ByteBuffer data) |
public NioFiberImpl()
public NioFiberImpl(NioBatchExecutor executor, Collection<NioChannelHandler> handlers)
public NioFiberImpl(NioBatchExecutor executor, Collection<NioChannelHandler> nioHandlers, String threadName, boolean isDaemonThread, NioFiberImpl.WriteFailure writeFailed, NioFiberImpl.OnBuffer onBuffer)
public static void writeAll(WritableByteChannel channel, ByteBuffer data) throws IOException
IOException
public Thread getThread()
public static ByteBuffer addTo(ByteBuffer data, ByteBuffer buffer)
public void addHandler(NioChannelHandler handler)
addHandler
in interface NioFiber
public void execute(Callback<NioControls> asyncWrite)
public void add(Disposable disposable)
DisposingExecutor
Disposable
to be disposed when this component is disposedadd
in interface DisposingExecutor
disposable
- Disposable instance. Should not be null.public boolean remove(Disposable disposable)
DisposingExecutor
Disposable
from being disposed when this component is disposedremove
in interface DisposingExecutor
disposable
- Disposable instance. Should not be nullpublic int size()
DisposingExecutor
Disposable
instances registered with this instance.
This method is typically used for testing and debugging purposes.size
in interface DisposingExecutor
Disposable
instances registered.public Disposable schedule(Runnable command, long delay, TimeUnit unit)
Scheduler
public Disposable scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
Scheduler
scheduleWithFixedDelay
in interface Scheduler
command
- the task to executeinitialDelay
- the time to delay first executiondelay
- the delay between the termination of one
execution and the commencement of the nextunit
- the time unit of the initialDelay and delay parameterspublic Disposable scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
Scheduler
scheduleAtFixedRate
in interface Scheduler
command
- the task to executeinitialDelay
- the time to delay first executionperiod
- the delayunit
- the time unit of the initialDelay and delay parameterspublic void dispose()
Disposable
dispose
in interface Disposable
public void start()
Fiber
Copyright © 2017. All Rights Reserved.