public class AgentRunner
extends java.lang.Object
implements java.lang.Runnable, java.lang.AutoCloseable
Agent and ensuring exceptions are handled.
Note: An agent runner should only be once per instance.
| Constructor and Description |
|---|
AgentRunner(IdleStrategy idleStrategy,
ErrorHandler errorHandler,
AtomicCounter errorCounter,
Agent agent)
Create an agent passing in
IdleStrategy |
| Modifier and Type | Method and Description |
|---|---|
Agent |
agent()
The
Agent who's lifecycle is being managed. |
void |
close()
Stop the running Agent and cleanup.
|
void |
run()
Run an
Agent. |
static java.lang.Thread |
startOnThread(AgentRunner runner)
Start the given agent runner on a new thread.
|
static java.lang.Thread |
startOnThread(AgentRunner runner,
java.util.concurrent.ThreadFactory threadFactory)
Start the given agent runner on a new thread.
|
public AgentRunner(IdleStrategy idleStrategy, ErrorHandler errorHandler, AtomicCounter errorCounter, Agent agent)
IdleStrategyidleStrategy - to use for Agent run looperrorHandler - to be called if an Throwable is encounterederrorCounter - for reporting how many exceptions have been seen.agent - to be run in this thread.public static java.lang.Thread startOnThread(AgentRunner runner)
runner - the agent runner to startpublic static java.lang.Thread startOnThread(AgentRunner runner, java.util.concurrent.ThreadFactory threadFactory)
runner - the agent runner to start.threadFactory - the factory to use to create the thread.public Agent agent()
Agent who's lifecycle is being managed.Agent who's lifecycle is being managed.public void run()
run in interface java.lang.Runnablepublic final void close()
Agent performing
it Agent.onClose() logic.
The clean up logic will only be performed once even if close is called from multiple concurrent threads.
close in interface java.lang.AutoCloseableCopyright © 2014 - 2016 Real Logic Ltd. All Rights Reserved.