Interface Kernel
- All Known Implementing Classes:
AbstractKernel, SelectorKernel, UdpKernel
public interface Kernel
Defines the basic byte[] passing messaging
kernel.
- Author:
- Paul Speed
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EnvelopeA marker envelope returned from read() that indicates that there are events pending. -
Method Summary
Modifier and TypeMethodDescriptionvoidbroadcast(Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy) Dispatches the data to all endpoints managed by the kernel that match the specified endpoint filter.booleanReturns true if there are waiting envelopes.voidInitializes the kernel and starts any internal processing.Removes and returns one endpoint event from the event queue or null if there are no endpoint events.read()Removes one envelope from the received messages queue or blocks until one is available.voidGracefully terminates the kernel and stops any internal daemon processing.
-
Field Details
-
EVENTS_PENDING
A marker envelope returned from read() that indicates that there are events pending. This allows a single thread to more easily process the envelopes and endpoint events.
-
-
Method Details
-
initialize
void initialize()Initializes the kernel and starts any internal processing. -
terminate
Gracefully terminates the kernel and stops any internal daemon processing. This method will not return until all internal threads have been shut down.- Throws:
InterruptedException- if the calling thread is interrupted while waiting
-
broadcast
Dispatches the data to all endpoints managed by the kernel that match the specified endpoint filter. If 'copy' is true then the implementation will copy the byte buffer before delivering it to endpoints. This allows the caller to reuse the data buffer. Though it is important that the buffer not be changed by another thread while this call is running. Only the bytes from data.position() to data.remaining() are sent.- Parameters:
filter- the endpoint filter used to select recipientsdata- the payload to sendreliable- true to use reliable transport semanticscopy- true to copy the buffer before dispatching it
-
hasEnvelopes
boolean hasEnvelopes()Returns true if there are waiting envelopes.- Returns:
- true if at least one envelope is queued
-
read
Removes one envelope from the received messages queue or blocks until one is available.- Returns:
- the next queued envelope
- Throws:
InterruptedException- if interrupted while waiting for an envelope
-
nextEvent
EndpointEvent nextEvent()Removes and returns one endpoint event from the event queue or null if there are no endpoint events.- Returns:
- the next endpoint event, or null if none are queued
-