public class DefaultBuckEventBus extends Object implements BuckEventBus
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SHUTDOWN_TIMEOUT_MS |
Constructor and Description |
---|
DefaultBuckEventBus(Clock clock,
boolean async,
BuildId buildId,
int shutdownTimeoutMillis) |
DefaultBuckEventBus(Clock clock,
BuildId buildId) |
DefaultBuckEventBus(Clock clock,
BuildId buildId,
int shutdownTimeoutMillis,
ExecutorService executorService) |
Modifier and Type | Method and Description |
---|---|
void |
close()
ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit) is called to wait
for events which have been posted, but which have been queued by the EventBus , to be
delivered. |
BuildId |
getBuildId()
An id that every event posted to this event bus will share.
|
void |
post(BuckEvent event) |
void |
post(BuckEvent event,
BuckEvent atTime)
Post event to the EventBus using the timestamp given by atTime.
|
void |
postWithoutConfiguring(BuckEvent event) |
void |
register(Object object)
Register a listener to process events
|
void |
timestamp(BuckEvent event)
Timestamp event.
|
void |
unregister(Object object)
Remove a listener previously specified with
register() |
boolean |
waitEvents(long timeout)
Wait for all currently running events to dispatch and finish executing
|
public static final int DEFAULT_SHUTDOWN_TIMEOUT_MS
public DefaultBuckEventBus(Clock clock, boolean async, BuildId buildId, int shutdownTimeoutMillis)
public DefaultBuckEventBus(Clock clock, BuildId buildId, int shutdownTimeoutMillis, ExecutorService executorService)
public void post(BuckEvent event)
post
in interface EventDispatcher
public void post(BuckEvent event, BuckEvent atTime)
post
in interface EventDispatcher
public void register(Object object)
BuckEventBus
register
in interface BuckEventBus
public void unregister(Object object)
BuckEventBus
register()
unregister
in interface BuckEventBus
public void postWithoutConfiguring(BuckEvent event)
postWithoutConfiguring
in interface EventDispatcher
public BuildId getBuildId()
In practice, this should be a short string, because it may be sent over the wire frequently.
getBuildId
in interface BuckEventBus
public void close()
ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)
is called to wait
for events which have been posted, but which have been queued by the EventBus
, to be
delivered. This allows listeners to record or report as much information as possible. This aids
debugging when close is called during exception processing.close
in interface Closeable
close
in interface AutoCloseable
public boolean waitEvents(long timeout)
BuckEventBus
waitEvents
in interface BuckEventBus
timeout
- Time in milliseconds to wait for completion, if timeout is not greater than 0
then it will wait indefinitelypublic void timestamp(BuckEvent event)
timestamp
in interface EventDispatcher