Code example for AtomicReference

Methods: getAndSet

0
	/** Indicates if this session is keep alive */ 
	protected final boolean keepAlive; 
	/** The client specified timeout */ 
	protected final long timeout;
	/** The current timeout */ 
	protected AtomicReference<Timeout> timerTimeout = new AtomicReference<Timeout>(null);
	 
	/** The timer for implementing timeouts */ 
	protected static final HashedWheelTimer timer = new HashedWheelTimer();
	/** Instance logger */ 
	protected final Logger log; 
	 
	static { 
		timer.start();
	} 
	 
	/** 
	 * Creates a new TimeoutChannel 
	 * @param channel The channel to wrap 
	 * @param timeout The client specified timeout in ms. 
	 * @param keepAlive Indicates if this session is keep alive 
	 */ 
	public TimeoutChannel(Channel channel, long timeout, boolean keepAlive) {
		this.channel = channel;
		this.timeout = timeout;
		this.keepAlive = keepAlive;
		log = Logger.getLogger(getClass().getName() + "." + channel.getId());
		timerTimeout.getAndSet(timer.newTimeout(this, this.timeout, TimeUnit.MILLISECONDS));
		//SharedChannelGroup.getInstance().add(this); 
	} 
	 
	/** 
	 * Called when the channels timeout fires.