Driver.Factory
Constructor and Description |
---|
DriverImpl() |
Modifier and Type | Method and Description |
---|---|
Connector |
connector()
Get the next active connector in the driver.
|
Iterable<Connector> |
connectors()
Return an iterator over all connectors.
|
<C> Connector<C> |
createConnector(SelectableChannel c,
C context)
Create a connector using the existing file descriptor.
|
<C> Connector<C> |
createConnector(String host,
int port,
C context)
Construct a connector to the given remote address.
|
<C> Listener<C> |
createListener(ServerSocketChannel c,
C context)
Create a listener using the existing channel.
|
<C> Listener<C> |
createListener(String host,
int port,
C context)
Construct a listener for the given address.
|
protected <C> Connector<C> |
createServerConnector(SelectableChannel c,
C context,
Listener<C> l) |
void |
destroy()
Destruct the driver and all associated listeners, connectors and other resources.
|
boolean |
doWait(long timeout)
Wait for an active connector or listener, or for
Driver.wakeup() to be called. |
Listener |
listener()
Get the next listener with pending data in the driver.
|
Iterable<Listener> |
listeners()
Return an iterator over all listeners.
|
<C> void |
removeConnector(Connector<C> c) |
void |
wakeup()
Force
Driver.doWait(long) to return. |
public DriverImpl() throws IOException
IOException
public void wakeup()
Driver
Driver.doWait(long)
to return.
If the driver is not currently waiting then the next invocation of Driver.doWait(long)
will return immediately unless the Driver.connector()
method is invoked in the meantime.
Thread-safe.public boolean doWait(long timeout)
Driver
Driver.wakeup()
to be called.
Thread-safe.public Listener listener()
Driver
public Connector connector()
Driver
Driver.wakeup()
.public void destroy()
Driver
public <C> Listener<C> createListener(String host, int port, C context)
Driver
createListener
in interface Driver
host
- local host address to listen onport
- local port to listen oncontext
- application-supplied, can be accessed via
getContext()
method on a listener.public <C> Listener<C> createListener(ServerSocketChannel c, C context)
Driver
createListener
in interface Driver
c
- existing SocketChannel for listener to listen oncontext
- application-supplied, can be accessed via
getContext()
method on a listener.public <C> Connector<C> createConnector(String host, int port, C context)
Driver
createConnector
in interface Driver
host
- remote host to connect to.port
- remote port to connect to.context
- application-supplied, can be accessed via
getContext()
method on a listener.public <C> Connector<C> createConnector(SelectableChannel c, C context)
Driver
createConnector
in interface Driver
c
- existing SocketChannel for listener to listen oncontext
- application-supplied, can be accessed via
getContext()
method on a listener.public <C> void removeConnector(Connector<C> c)
public Iterable<Listener> listeners()
Driver
public Iterable<Connector> connectors()
Driver
connectors
in interface Driver
protected <C> Connector<C> createServerConnector(SelectableChannel c, C context, Listener<C> l)
Copyright © 2016 The Apache Software Foundation. All rights reserved.