- java.lang.Object
-
- swim.io.Station
-
public class Station extends Object
Asynchronous I/O multiplexor.
-
-
Field Summary
Fields Modifier and Type Field Description protected StagestageStage on which to execute I/O tasks.protected TransportSettingstransportSettingsTransport configuration parameters.
-
Constructor Summary
Constructors Constructor Description Station(Stage stage)Station(Stage stage, TransportSettings transportSettings)
-
Method Summary
Modifier and Type Method Description protected voiddidFail(Throwable error)Lifecycle callback invoked if the selector thread throws a fatalerror.protected voiddidStart()Lifecycle callback invoked after the selector thread starts.protected voiddidStop()Lifecycle callback invoked after the selector thread stops.Stagestage()Returns theStageon which thisStationexecutes I/O tasks.voidstart()Ensures that thisStationis up and running, starting up the selector thread if it has not yet been started.voidstop()Ensures that thisStationhas been permanently stopped, shutting down the selector thread, if it's currently running.TransportReftransport(Transport transport, FlowControl flowControl)Binds the giventransportto thisStation, initializing thetransport's context with the givenflowControlstate.protected voidtransportDidAccept(Transport transport)Introspection callback invoked after atransportcompletes an accept operation.protected voidtransportDidClose(Transport transport)Introspection callback invoked after atransportcloses.protected voidtransportDidConnect(Transport transport)Introspection callback invoked after atransportcompletes a connect operation.protected voidtransportDidFail(Transport transport, Throwable error)Introspection callback invoked after atransportoperation fails by throwing anerror.protected voidtransportDidTimeout(Transport transport)Introspection callback invoked after atransporttimes out.TransportSettingstransportSettings()Returns the transport configuration parameters that govern thisStation's regsitered transports.StationtransportSettings(TransportSettings transportSettings)Updates the transport configuration parameters that govern thisStation's registered transports, and returnsthis.protected voidwillStart()Lifecycle callback invoked before the selector thread starts.protected voidwillStop()Lifecycle callback invoked before the selector thread stops.
-
-
-
Field Detail
-
stage
protected final Stage stage
Stage on which to execute I/O tasks.
-
transportSettings
protected TransportSettings transportSettings
Transport configuration parameters.
-
-
Constructor Detail
-
Station
public Station(Stage stage, TransportSettings transportSettings)
-
Station
public Station(Stage stage)
-
-
Method Detail
-
stage
public final Stage stage()
Returns theStageon which thisStationexecutes I/O tasks.
-
transportSettings
public final TransportSettings transportSettings()
Returns the transport configuration parameters that govern thisStation's regsitered transports.
-
transportSettings
public Station transportSettings(TransportSettings transportSettings)
Updates the transport configuration parameters that govern thisStation's registered transports, and returnsthis.
-
start
public void start()
Ensures that thisStationis up and running, starting up the selector thread if it has not yet been started.- Throws:
StationException- if thisStationhas been stopped.
-
stop
public void stop()
Ensures that thisStationhas been permanently stopped, shutting down the selector thread, if it's currently running. Upon return, thisStationis guaranteed to be in the stopped state.
-
transport
public TransportRef transport(Transport transport, FlowControl flowControl)
Binds the giventransportto thisStation, initializing thetransport's context with the givenflowControlstate. TheStationthereafter asynchronously executes I/O tasks on behalf of thetransportwhen the underlying physical transport is ready for I/O operations permitted by thetransport's current flow control state. Returns aTransportRef, which can be used to modify the flow control of thetransport, and to close thetransport.
-
willStart
protected void willStart()
Lifecycle callback invoked before the selector thread starts.
-
didStart
protected void didStart()
Lifecycle callback invoked after the selector thread starts.
-
willStop
protected void willStop()
Lifecycle callback invoked before the selector thread stops.
-
didStop
protected void didStop()
Lifecycle callback invoked after the selector thread stops.
-
didFail
protected void didFail(Throwable error)
Lifecycle callback invoked if the selector thread throws a fatalerror. The selector thread will stop after invokingdidFail.
-
transportDidAccept
protected void transportDidAccept(Transport transport)
Introspection callback invoked after atransportcompletes an accept operation.
-
transportDidConnect
protected void transportDidConnect(Transport transport)
Introspection callback invoked after atransportcompletes a connect operation.
-
transportDidTimeout
protected void transportDidTimeout(Transport transport)
Introspection callback invoked after atransporttimes out.
-
transportDidClose
protected void transportDidClose(Transport transport)
Introspection callback invoked after atransportcloses.
-
-