View Javadoc

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