Sl4aEventDispatcher
public
class
Sl4aEventDispatcher
extends Object
java.lang.Object | |
↳ | com.android.tradefed.util.sl4a.Sl4aEventDispatcher |
Event dispatcher polls for event and queue them by name to be queried. TODO: add support for event handlers.
Summary
Nested classes | |
---|---|
class |
Sl4aEventDispatcher.EventSl4aObject
Object returned by the event poller. |
Fields | |
---|---|
public
static
final
String |
SHUTDOWN_EVENT
|
Public constructors | |
---|---|
Sl4aEventDispatcher(Sl4aClient client, long timeout)
|
Public methods | |
---|---|
void
|
cancel()
Stop the thread execution and clean up all the events. |
void
|
clearAllEvents()
clear all the events |
void
|
clearEvents(String name)
Clear all the events for one event name. |
|
popAllEvents(String name)
Return all the events of one type, or empty list if no event. |
Sl4aEventDispatcher.EventSl4aObject
|
popEvent(String name, long timeout)
Poll for one event by name |
void
|
run()
|
Sl4aEventDispatcher.EventSl4aObject
|
waitForEvent(String name,
Poll for a particular event that match the name and predicate. |
Protected methods | |
---|---|
boolean
|
internalPolling()
Internal polling of events, should not be called. |
Fields
SHUTDOWN_EVENT
public static final String SHUTDOWN_EVENT
Public constructors
Sl4aEventDispatcher
public Sl4aEventDispatcher (Sl4aClient client, long timeout)
Parameters | |
---|---|
client |
Sl4aClient |
timeout |
long |
Public methods
cancel
public void cancel ()
Stop the thread execution and clean up all the events.
clearAllEvents
public void clearAllEvents ()
clear all the events
clearEvents
public void clearEvents (String name)
Clear all the events for one event name.
Parameters | |
---|---|
name |
String |
popAllEvents
publicpopAllEvents (String name)
Return all the events of one type, or empty list if no event.
Parameters | |
---|---|
name |
String |
Returns | |
---|---|
|
popEvent
public Sl4aEventDispatcher.EventSl4aObject popEvent (String name, long timeout)
Poll for one event by name
Parameters | |
---|---|
name |
String : the name of the event. |
timeout |
long : the timeout in millisecond for the pop event to return. |
Returns | |
---|---|
Sl4aEventDispatcher.EventSl4aObject |
the EventSl4aObject or null if no event found. |
run
public void run ()
waitForEvent
public Sl4aEventDispatcher.EventSl4aObject waitForEvent (String name,predicate, long timeout)
Poll for a particular event that match the name and predicate.
Parameters | |
---|---|
name |
String : the name of the event. |
predicate |
: the predicate the event needs to pass. |
timeout |
long : timeout the timeout in millisecond for the pop event to return. |
Returns | |
---|---|
Sl4aEventDispatcher.EventSl4aObject |
the EventSl4aObject or null if no event found. |
Protected methods
internalPolling
protected boolean internalPolling ()
Internal polling of events, should not be called. Exposed for testing.
Returns | |
---|---|
boolean |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-03-08 UTC.