Code example for AtomicReference

Methods: getAndSet

0
	 
	/** 
	 * Resets the timeout on this channel 
	 */ 
	protected void resetTimer() { 
		Timeout t = timerTimeout.getAndSet(timer.newTimeout(this, this.timeout, TimeUnit.MILLISECONDS));
		if(t!=null) {
			t.cancel();
		} 
	} 
	 
	/** 
	 * When a write request is processed, the timeout is reset. 
	 * {@inheritDoc} 
	 * @see org.jboss.netty.channel.Channel#write(java.lang.Object) 
	 */ 
	public ChannelFuture write(Object message) {
		SharedChannelGroup.getInstance().remove(this);
		return channel.write(message);
	}