Class AbstractKernel
java.lang.Object
com.jme3.network.kernel.AbstractKernel
- All Implemented Interfaces:
Kernel
- Direct Known Subclasses:
SelectorKernel, UdpKernel
Base implementation of the Kernel interface providing several
useful default implementations of some methods. This implementation
assumes that the kernel will be managing its own internal threads
and queuing any results for the caller to retrieve on their own
thread.
- Author:
- Paul Speed
-
Field Summary
Fields inherited from interface Kernel
EVENTS_PENDING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a kernel base with empty event and envelope queues. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddEnvelope(Envelope env) Adds an envelope to the pending message queue.protected voidAdds an endpoint event to the pending event queue.booleanReturns true if there are waiting envelopes.protected longReturns the next unique endpoint identifier.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.protected voidReports an internal kernel error.protected voidWakes a waiting reader by enqueueing theKernel.EVENTS_PENDINGmarker if needed.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Kernel
broadcast, initialize, terminate
-
Constructor Details
-
AbstractKernel
protected AbstractKernel()Creates a kernel base with empty event and envelope queues.
-
-
Method Details
-
reportError
Reports an internal kernel error.- Parameters:
e- the error to report
-
wakeupReader
protected void wakeupReader()Wakes a waiting reader by enqueueing theKernel.EVENTS_PENDINGmarker if needed. -
nextEndpointId
protected long nextEndpointId()Returns the next unique endpoint identifier.- Returns:
- the next endpoint id
-
hasEnvelopes
public boolean hasEnvelopes()Returns true if there are waiting envelopes.- Specified by:
hasEnvelopesin interfaceKernel- Returns:
- true if at least one envelope is queued
-
read
Removes one envelope from the received messages queue or blocks until one is available.- Specified by:
readin interfaceKernel- Returns:
- the next queued envelope
- Throws:
InterruptedException- if interrupted while waiting for an envelope
-
nextEvent
Removes and returns one endpoint event from the event queue or null if there are no endpoint events. -
addEvent
Adds an endpoint event to the pending event queue.- Parameters:
e- the event to enqueue
-
addEnvelope
Adds an envelope to the pending message queue.- Parameters:
env- the envelope to enqueue
-