Mercurial > hg > Members > nobuyasu > tightVNCProxy
annotate src/myVncProxy/MostRecentMultiCast.java @ 168:f7f4c3fdbbea
update
author | one |
---|---|
date | Sat, 10 Sep 2011 04:11:30 +0900 |
parents | 0cbe556e2c54 |
children |
rev | line source |
---|---|
82
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 package myVncProxy; |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 import java.util.LinkedList; |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 public class MostRecentMultiCast<T> extends MulticastQueue<T> { |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 LinkedList<Node<T>> alive; |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 int count = 0; |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 MostRecentMultiCast(int limit) { |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 count = limit; |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 this.alive = new LinkedList<Node<T>>(); |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 } |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 @Override |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 public synchronized void put(T item) |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 { |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 Node<T> next = new Node<T>(item); |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 tail.set(next); |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 tail = next; |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 alive.addLast(next); |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 if (alive.size()>count) { |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 Node<T> old = alive.getFirst(); |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 old.clear(); |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 } |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 } |
0cbe556e2c54
remove item to reduce memory
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 } |