diff src/myVncProxy/MostRecentMultiCast.java @ 82:0cbe556e2c54

remove item to reduce memory
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 03 Aug 2011 04:26:58 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/myVncProxy/MostRecentMultiCast.java	Wed Aug 03 04:26:58 2011 +0900
@@ -0,0 +1,27 @@
+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();
+		}
+	}
+}