< prev index next >
src/java.httpclient/share/classes/java/net/http/AsyncEvent.java
Print this page
*** 23,50 ****
*/
package java.net.http;
import java.nio.channels.SelectableChannel;
/**
* Event handling interface from HttpClientImpl's selector.
*
! * <p> If blockingChannel is true, then the channel will be put in blocking
* mode prior to handle() being called. If false, then it remains non-blocking.
*/
abstract class AsyncEvent {
! /**
! * Implement this if channel should be made blocking before calling handle()
! */
! public interface Blocking { }
! /**
! * Implement this if channel should remain non-blocking before calling handle()
! */
! public interface NonBlocking { }
/** Returns the channel */
public abstract SelectableChannel channel();
/** Returns the selector interest op flags OR'd */
--- 23,53 ----
*/
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.
*
! * 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 {
! public static final int BLOCKING = 0x1; // non blocking if not set
! public static final int REPEATING = 0x2; // one off event if not set
! 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,58 ****
--- 56,69 ----
/** 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 >