view src/myVncProxy/MostRecentMultiCast.java @ 168:f7f4c3fdbbea

update
author one
date Sat, 10 Sep 2011 04:11:30 +0900
parents 0cbe556e2c54
children
line wrap: on
line source

package myVncProxy;

import java.util.LinkedList;


public class MostRecentMultiCast<T> extends MulticastQueue<T> {

	LinkedList<Node<T>> alive;
	int count = 0;
	MostRecentMultiCast(int limit) {
		count = limit;
		this.alive = new LinkedList<Node<T>>();
	}

	@Override
	public synchronized void put(T item)
	{
		Node<T> next = new Node<T>(item);
		tail.set(next);
		tail = next;
		alive.addLast(next);
		if (alive.size()>count) {
			Node<T> old = alive.getFirst();
			old.clear();
		}
	}
}