Przeglądaj źródła

sailfish-0.0.46
去掉没用的synchronized

menglu 3 lat temu
rodzic
commit
ac65cb6bd6

+ 1 - 1
ibms-data-sdk/pom.xml

@@ -220,7 +220,7 @@
 		<dependency>
 			<groupId>com.persagy</groupId>
 			<artifactId>sailfish</artifactId>
-			<version>0.0.45</version>
+			<version>0.0.46</version>
 		</dependency>
 	</dependencies>
 

+ 3 - 3
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/websocket/server/WebSocketHandler.java

@@ -88,18 +88,18 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
 
 	}
 
-	private synchronized void handlerConnect(Channel channel) {
+	private void handlerConnect(Channel channel) {
 		String id = channel.id().asLongText();
 		WebSocketChannelPool.id2Channel.put(id, channel);
 		WebSocketChannelPool.id2ChannelInfo.put(id, new WebSocketChannelInfo(channel.remoteAddress(), new Date()));
 	}
 
-	private synchronized void handlerReceive(Channel channel, Object ContentJSON) {
+	private void handlerReceive(Channel channel, Object ContentJSON) {
 		String id = channel.id().asLongText();
 		WebSocketUtil.ProcessReceive(id, ContentJSON);
 	}
 
-	private synchronized void handlerDisconnect(Channel channel) {
+	private void handlerDisconnect(Channel channel) {
 		try {
 			String id = channel.id().asLongText();
 			WebSocketChannelPool.id2Channel.remove(id);

+ 6 - 7
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/PacketBuffer.java

@@ -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();
 	}
 }