public class Timeout extends java.lang.Object implements java.lang.Comparable<Timeout>
TimeoutWorker
. Timeouts
are associated with a SocketIF
and a TimeoutListener
. When a
timeout is expired, it notifies the listener of the expiration, at which time
the listener should act on the timeout (e.g. closing the socket, performing
an SSL/TLS re-handshake and so on).TimeoutWorker
,
TimeoutWorker
Modifier and Type | Field and Description |
---|---|
static int |
GENERIC_TIMEOUT
Unused TODO
|
static int |
SSL_TIMEOUT
Unused TODO
|
Constructor and Description |
---|
Timeout(SocketIF socket,
TimeoutListener listener,
long timeout)
Create a new timeout for the
SocketIF given. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Timeout t)
Overrides the
Comparable interface to allow timeouts to be
compared. |
void |
expired()
Sets this timeout to expired state, firing any attached listeners in the
process.
|
long |
getCreated()
Get the time this timeout was created
|
long |
getDelta()
Get the absolute expiration time of this timeout
|
SocketIF |
getSocket()
Get the
SocketIF this timeout is associated with |
long |
getTimeout()
Get the timeout period
|
boolean |
hasExpired()
Whether or not this timeout already had its associated
expired()
method called and had its TimeoutListener fired. |
boolean |
isExpired()
Check whether or not this timeout is expired right now.
|
public static final int SSL_TIMEOUT
public static final int GENERIC_TIMEOUT
public Timeout(SocketIF socket, TimeoutListener listener, long timeout)
SocketIF
given. If the timeout
expires, it will fire TimeoutListener.timeoutExpired(SocketIF)
on
the associated listener.socket
- The socket the timeout is to be associated withlistener
- The listener listening for timeout expiration on this
sockettimeout
- The timeout periodpublic SocketIF getSocket()
SocketIF
this timeout is associated withSocketIF
this timeout is associated withpublic long getTimeout()
public long getCreated()
public long getDelta()
public void expired()
public boolean isExpired()
expired()
, time checking is not
performed, returning true directly.public boolean hasExpired()
expired()
method called and had its TimeoutListener
fired.expired()
method called and had its TimeoutListener
fired.public int compareTo(Timeout t)
Comparable
interface to allow timeouts to be
compared. Timeouts are compared based on their absolute expiration times.compareTo
in interface java.lang.Comparable<Timeout>
t
- The timeout to compare to