public class ThreadFiber extends Object implements Fiber
Constructor and Description |
---|
ThreadFiber() |
ThreadFiber(RunnableExecutor queue,
String threadName,
boolean isDaemonThread) |
ThreadFiber(RunnableExecutor queue,
String threadName,
boolean isDaemonThread,
Scheduler scheduler)
Create thread backed fiber
|
Modifier and Type | Method and Description |
---|---|
void |
add(Disposable runOnStop)
Add a
Disposable to be disposed when this component is disposed |
void |
dispose()
Dispose this instance.
|
void |
execute(Runnable command)
Queue runnable for execution on this fiber.
|
Thread |
getThread() |
void |
join()
Wait for thread to complete
|
boolean |
remove(Disposable disposable)
Remove a
Disposable from being disposed when this component is disposed |
Disposable |
schedule(Runnable command,
long delay,
TimeUnit unit)
Schedule a Runnable to execute in the future.
|
Disposable |
scheduleAtFixedRate(Runnable command,
long initialDelay,
long delay,
TimeUnit unit)
Schedule recurring event.
|
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 thread
|
public ThreadFiber(RunnableExecutor queue, String threadName, boolean isDaemonThread, Scheduler scheduler)
queue
- - target queuethreadName
- - name to assign threadisDaemonThread
- - true if daemon threadscheduler
- - scheduler for delayed taskspublic ThreadFiber(RunnableExecutor queue, String threadName, boolean isDaemonThread)
public ThreadFiber()
public Thread getThread()
public void execute(Runnable command)
public void add(Disposable runOnStop)
DisposingExecutor
Disposable
to be disposed when this component is disposedadd
in interface DisposingExecutor
runOnStop
- 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 void dispose()
Disposable
dispose
in interface Disposable
public void join() throws InterruptedException
InterruptedException
public Disposable schedule(Runnable command, long delay, TimeUnit unit)
public Disposable scheduleAtFixedRate(Runnable command, long initialDelay, long delay, TimeUnit unit)
scheduleAtFixedRate
in interface Scheduler
command
- the task to executeinitialDelay
- the time to delay first executiondelay
- the delayunit
- the time unit of the initialDelay and delay parameterspublic 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 parametersCopyright © 2017. All Rights Reserved.