コード例 #1
0
 /** @see FileQueue#get() */
 public T get() {
   MemCachedMessage<T> msg = null;
   getLock.lock();
   try {
     msg = memcacheQueue.take();
     lastMsg.set(msg);
     commitMessage();
   } catch (InterruptedException e) {
     log.warn("interrupted when taking messsage from SeqFileStorage");
     Thread.currentThread().interrupt();
   } finally {
     getLock.unlock();
   }
   return msg == null ? null : msg.getData();
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  *
  * @see com.dp.hippo.queue.FileQueue#get(long,
  * java.util.concurrent.TimeUnit)
  */
 @Override
 public T get(long timeout, TimeUnit timeUnit) {
   MemCachedMessage<T> msg = null;
   getLock.lock();
   try {
     msg = memcacheQueue.poll(timeout, timeUnit);
     if (msg == null) {
       return null;
     }
     lastMsg.set(msg);
     commitMessage();
   } catch (InterruptedException e) {
     log.warn("interrupted when taking messsage from SeqFileStorage");
     Thread.currentThread().interrupt();
   } finally {
     getLock.unlock();
   }
   return msg == null ? null : msg.getData();
 }