|
@@ -1,15 +1,14 @@
|
|
|
package com.persagy.ibms.data.sdk.util;
|
|
|
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.Queue;
|
|
|
+import java.util.concurrent.ConcurrentLinkedQueue;
|
|
|
|
|
|
public class PacketBuffer<T> {
|
|
|
- private Queue<T> buffer = new LinkedList<T>();
|
|
|
+ private ConcurrentLinkedQueue<T> buffer = new ConcurrentLinkedQueue<T>();
|
|
|
|
|
|
public PacketBuffer() {
|
|
|
}
|
|
|
|
|
|
- public synchronized boolean offer(T packet, int size) {
|
|
|
+ public boolean offer(T packet, int size) {
|
|
|
if (this.buffer.size() >= size) {
|
|
|
return false;
|
|
|
}
|
|
@@ -18,17 +17,17 @@ public class PacketBuffer<T> {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public synchronized T poll() {
|
|
|
+ public T poll() {
|
|
|
T MyPackage = this.buffer.poll();
|
|
|
return MyPackage;
|
|
|
}
|
|
|
|
|
|
- public synchronized T take() {
|
|
|
+ public T take() {
|
|
|
T MyPackage = this.buffer.peek();
|
|
|
return MyPackage;
|
|
|
}
|
|
|
|
|
|
- public synchronized int BufferSize() {
|
|
|
+ public int BufferSize() {
|
|
|
return this.buffer.size();
|
|
|
}
|
|
|
}
|