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 to a thread to attend to it.
23       * 
24       */
25      public void asyncDispatch();
26      
27      /* ------------------------------------------------------------ */
28      /** Schedule a write dispatch.
29       * Set the endpoint to not be writable and schedule a dispatch when
30       * it becomes writable.
31       */
32      public void scheduleWrite();  
33  
34      /* ------------------------------------------------------------ */
35      /** Callback when idle.
36       * <p>An endpoint is idle if there has been no IO activity for 
37       * {@link #getMaxIdleTime()} and {@link #isCheckForIdle()} is true.
38       */
39      public void onIdleExpired();
40  
41      /* ------------------------------------------------------------ */
42      /** Set if the endpoint should be checked for idleness
43       */
44      public void setCheckForIdle(boolean check);
45  
46      /* ------------------------------------------------------------ */
47      /** Get if the endpoint should be checked for idleness
48       */
49      public boolean isCheckForIdle();
50  
51      
52      /* ------------------------------------------------------------ */
53      public boolean isWritable();
54  
55      /* ------------------------------------------------------------ */
56      /**
57       * @return True if IO has been successfully performed since the last call to {@link #hasProgressed()}
58       */
59      public boolean hasProgressed();
60      
61      /* ------------------------------------------------------------ */
62      /**
63       */
64      public void scheduleTimeout(Timeout.Task task, long timeoutMs);
65  
66      /* ------------------------------------------------------------ */
67      /**
68       */
69      public void cancelTimeout(Timeout.Task task);
70  }