1 //
2 //  ========================================================================
3 //  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4 //  ------------------------------------------------------------------------
5 //  All rights reserved. This program and the accompanying materials
6 //  are made available under the terms of the Eclipse Public License v1.0
7 //  and Apache License v2.0 which accompanies this distribution.
8 //
9 //      The Eclipse Public License is available at
10 //      http://www.eclipse.org/legal/epl-v10.html
11 //
12 //      The Apache License v2.0 is available at
13 //      http://www.opensource.org/licenses/apache2.0.php
14 //
15 //  You may elect to redistribute this code under either of these licenses.
16 //  ========================================================================
17 //
18 
19 package org.eclipse.jetty.io;
20 
21 import org.eclipse.jetty.util.thread.Timeout;
22 
23 public interface AsyncEndPoint extends ConnectedEndPoint
24 {
25     /* ------------------------------------------------------------ */
26     /**
27      * Dispatch the endpoint if it is not already dispatched
28      *
29      */
dispatch()30     public void dispatch();
31 
32     /* ------------------------------------------------------------ */
33     /**
34      * Dispatch the endpoint. If it is already dispatched, schedule a redispatch
35      *
36      */
asyncDispatch()37     public void asyncDispatch();
38 
39     /* ------------------------------------------------------------ */
40     /** Schedule a write dispatch.
41      * Set the endpoint to not be writable and schedule a dispatch when
42      * it becomes writable.
43      */
scheduleWrite()44     public void scheduleWrite();
45 
46     /* ------------------------------------------------------------ */
47     /** Callback when idle.
48      * <p>An endpoint is idle if there has been no IO activity for
49      * {@link #getMaxIdleTime()} and {@link #isCheckForIdle()} is true.
50      * @param idleForMs TODO
51      */
onIdleExpired(long idleForMs)52     public void onIdleExpired(long idleForMs);
53 
54     /* ------------------------------------------------------------ */
55     /** Set if the endpoint should be checked for idleness
56      */
setCheckForIdle(boolean check)57     public void setCheckForIdle(boolean check);
58 
59     /* ------------------------------------------------------------ */
60     /** Get if the endpoint should be checked for idleness
61      */
isCheckForIdle()62     public boolean isCheckForIdle();
63 
64 
65     /* ------------------------------------------------------------ */
isWritable()66     public boolean isWritable();
67 
68     /* ------------------------------------------------------------ */
69     /**
70      * @return True if IO has been successfully performed since the last call to {@link #hasProgressed()}
71      */
hasProgressed()72     public boolean hasProgressed();
73 
74     /* ------------------------------------------------------------ */
75     /**
76      */
scheduleTimeout(Timeout.Task task, long timeoutMs)77     public void scheduleTimeout(Timeout.Task task, long timeoutMs);
78 
79     /* ------------------------------------------------------------ */
80     /**
81      */
cancelTimeout(Timeout.Task task)82     public void cancelTimeout(Timeout.Task task);
83 }
84