diff src/main/java/com/glavsoft/rfb/protocol/MessageQueue.java @ 57:17b702648079

version2.7.2 original version.
author Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
date Sun, 15 Dec 2013 18:04:03 +0900
parents 4689cc86d6cb
children 3ede63861103
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/MessageQueue.java	Tue Jul 03 13:20:49 2012 +0900
+++ b/src/main/java/com/glavsoft/rfb/protocol/MessageQueue.java	Sun Dec 15 18:04:03 2013 +0900
@@ -1,4 +1,4 @@
-// Copyright (C) 2010, 2011 GlavSoft LLC.
+// Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC.
 // All rights reserved.
 //
 //-------------------------------------------------------------------------
@@ -24,10 +24,11 @@
 
 package com.glavsoft.rfb.protocol;
 
+import com.glavsoft.rfb.client.ClientToServerMessage;
+
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
-
-import com.glavsoft.rfb.client.ClientToServerMessage;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author dime at tightvnc.com
@@ -43,8 +44,15 @@
 		queue.offer(message);
 	}
 
+    /**
+     * Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
+     * Retrieves and removes the head of this queue, waiting up to the certain wait time if necessary for
+     * an element to become available.
+     * @return the head of this queue, or null if the specified waiting time elapses before an element is available
+     * @throws InterruptedException - if interrupted while waiting
+     */
 	public ClientToServerMessage get() throws InterruptedException {
-		return queue.take();
+		return queue.poll(1, TimeUnit.SECONDS);
 	}
 
 }