if (key != null) {
final KeyAttachment att = (KeyAttachment) key.attachment();
if ( att!=null ) {
+ //handle callback flag
+ if (att.getComet() && (interestOps & OP_CALLBACK) == OP_CALLBACK ) {
+ att.setCometNotify(true);
+ } else {
+ att.setCometNotify(false);
+ }
+ interestOps = (interestOps & (~OP_CALLBACK));//remove the callback flag
att.access();//to prevent timeout
//we are registering the key to start with, reset the fairness counter.
att.interestOps(interestOps);
}
public void cometInterest(NioChannel socket) {
- throw new UnsupportedOperationException();
+ KeyAttachment att = (KeyAttachment)socket.getAttachment(false);
+ add(socket,att.getCometOps());
}
public void wakeup() {
readLatch = null;
if ( writeLatch!=null ) try {for (int i=0; i<(int)writeLatch.getCount();i++) writeLatch.countDown();}catch (Exception ignore){}
writeLatch = null;
+ cometNotify = false;
+ cometOps = 0;
+ sendfileData = null;
}
public void reset() {
public void access(long access) { lastAccess = access; }
public void setComet(boolean comet) { this.comet = comet; }
public boolean getComet() { return comet; }
+ public void setCometNotify(boolean notify) { this.cometNotify = notify; }
+ public boolean getCometNotify() { return cometNotify; }
public void setCometOps(int ops) { this.cometOps = ops; }
public int getCometOps() { return cometOps; }
public boolean getCurrentAccess() { return currentAccess; }
public void setCurrentAccess(boolean access) { currentAccess = access; }
- public Object getMutex() {return mutex;}
public void setTimeout(long timeout) {this.timeout = timeout;}
public long getTimeout() {return this.timeout;}
public boolean getError() { return error; }
public void setSendfileData(SendfileData sf) { this.sendfileData = sf;}
public SendfileData getSendfileData() { return this.sendfileData;}
- protected Object mutex = new Object();
protected long lastAccess = -1;
protected boolean currentAccess = false;
protected boolean comet = false;
protected int cometOps = 0;
+ protected boolean cometNotify = false;
protected long timeout = -1;
protected boolean error = false;
protected NioChannel channel = null;