Reader¶
-
public class
Reader
extends Participant¶ Implements synchronous event receiving as a pattern on top of the usual asynchronous participant types. Clients have to continuously poll for new events by calling the #read() method. Internally, a queue is used to buffer received events.
- Author
jwienke
Constructors¶
Reader¶
-
public
Reader
(ReaderCreateArgs args, Factory factory)¶ Creates a new reader instance.
- Parameters
args – Arguments for creating the participant
factory – Factory instance used for creating the internal listener
- Throws
InitializeException – error initializing the reader
Methods¶
read¶
-
public Event
read
()¶ Read the next event without blocking. If available, returns the next event that was received.
- Throws
RSBException – reading the event failed
InterruptedException – interrupted while reading
- Returns
an event of
null
if no unread event was received yet.
read¶
-
public Event
read
(long timeout, TimeUnit unit)¶ Read the next event and block until one is available. Waits up to the specified amount of time for receiving the next event.
- Parameters
timeout – the amount of time to wait
unit – the unit of the amount of time to wait
- Throws
RSBException – reading the event failed
InterruptedException – interrupted while reading
- Returns
an event of
null
if no unread event was received until timeout.