- java.lang.Object
-
- swim.io.Station
-
public class Station extends Object
Asynchronous I/O multiplexor.
-
-
Field Summary
Fields Modifier and Type Field Description protected Stage
stage
Stage on which to execute I/O tasks.protected TransportSettings
transportSettings
Transport configuration parameters.
-
Constructor Summary
Constructors Constructor Description Station(Stage stage)
Station(Stage stage, TransportSettings transportSettings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
didFail(Throwable error)
Lifecycle callback invoked if the selector thread throws a fatalerror
.protected void
didStart()
Lifecycle callback invoked after the selector thread starts.protected void
didStop()
Lifecycle callback invoked after the selector thread stops.Stage
stage()
Returns theStage
on which thisStation
executes I/O tasks.void
start()
Ensures that thisStation
is up and running, starting up the selector thread if it has not yet been started.void
stop()
Ensures that thisStation
has been permanently stopped, shutting down the selector thread, if it's currently running.TransportRef
transport(Transport transport, FlowControl flowControl)
Binds the giventransport
to thisStation
, initializing thetransport
's context with the givenflowControl
state.protected void
transportDidAccept(Transport transport)
Introspection callback invoked after atransport
completes an accept operation.protected void
transportDidClose(Transport transport)
Introspection callback invoked after atransport
closes.protected void
transportDidConnect(Transport transport)
Introspection callback invoked after atransport
completes a connect operation.protected void
transportDidFail(Transport transport, Throwable error)
Introspection callback invoked after atransport
operation fails by throwing anerror
.protected void
transportDidTimeout(Transport transport)
Introspection callback invoked after atransport
times out.TransportSettings
transportSettings()
Returns the transport configuration parameters that govern thisStation
's regsitered transports.Station
transportSettings(TransportSettings transportSettings)
Updates the transport configuration parameters that govern thisStation
's registered transports, and returnsthis
.protected void
willStart()
Lifecycle callback invoked before the selector thread starts.protected void
willStop()
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 theStage
on which thisStation
executes 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 thisStation
is up and running, starting up the selector thread if it has not yet been started.- Throws:
StationException
- if thisStation
has been stopped.
-
stop
public void stop()
Ensures that thisStation
has been permanently stopped, shutting down the selector thread, if it's currently running. Upon return, thisStation
is guaranteed to be in the stopped state.
-
transport
public TransportRef transport(Transport transport, FlowControl flowControl)
Binds the giventransport
to thisStation
, initializing thetransport
's context with the givenflowControl
state. TheStation
thereafter asynchronously executes I/O tasks on behalf of thetransport
when 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 atransport
completes an accept operation.
-
transportDidConnect
protected void transportDidConnect(Transport transport)
Introspection callback invoked after atransport
completes a connect operation.
-
transportDidTimeout
protected void transportDidTimeout(Transport transport)
Introspection callback invoked after atransport
times out.
-
transportDidClose
protected void transportDidClose(Transport transport)
Introspection callback invoked after atransport
closes.
-
-