< prev index next >
src/java.httpclient/share/classes/java/net/http/AsyncEvent.java
Print this page
@@ -23,28 +23,31 @@
*/
package java.net.http;
import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
/**
* Event handling interface from HttpClientImpl's selector.
*
- * <p> If blockingChannel is true, then the channel will be put in blocking
+ * If BLOCKING is set, then the channel will be put in blocking
* mode prior to handle() being called. If false, then it remains non-blocking.
+ *
+ * If REPEATING is set then the event is not cancelled after being posted.
*/
abstract class AsyncEvent {
- /**
- * Implement this if channel should be made blocking before calling handle()
- */
- public interface Blocking { }
+ public static final int BLOCKING = 0x1; // non blocking if not set
+ public static final int REPEATING = 0x2; // one off event if not set
- /**
- * Implement this if channel should remain non-blocking before calling handle()
- */
- public interface NonBlocking { }
+ protected final int flags;
+
+ AsyncEvent(int flags) {
+ this.flags = flags;
+ }
/** Returns the channel */
public abstract SelectableChannel channel();
/** Returns the selector interest op flags OR'd */
@@ -53,6 +56,14 @@
/** Called when event occurs */
public abstract void handle();
/** Called when selector is shutting down. Abort all exchanges. */
public abstract void abort();
+
+ public boolean blocking() {
+ return (flags & BLOCKING) != 0;
+ }
+
+ public boolean repeating() {
+ return (flags & REPEATING) != 0;
+ }
}
< prev index next >