Ejemplo n.º 1
0
 /**
  * Get the command output and if the command hasn't completed yet, wait until it does.
  *
  * @return The command output.
  */
 @Override
 public T get() {
   try {
     latch.await();
     return output.get();
   } catch (InterruptedException e) {
     throw new RedisCommandInterruptedException(e);
   }
 }
Ejemplo n.º 2
0
 public <T> T await(Command<K, V, T> cmd, long timeout, TimeUnit unit) {
   if (!cmd.await(timeout, unit)) {
     cmd.cancel(true);
     throw new RedisException("Command timed out");
   }
   CommandOutput<K, V, T> output = cmd.getOutput();
   if (output.hasError()) throw new RedisException(output.getError());
   return output.get();
 }
Ejemplo n.º 3
0
 /**
  * Get the command output and if the command hasn't completed yet, wait up to the specified time
  * until it does.
  *
  * @param timeout Maximum time to wait for a result.
  * @param unit Unit of time for the timeout.
  * @return The command output.
  * @throws TimeoutException if the wait timed out.
  */
 @Override
 public T get(long timeout, TimeUnit unit) throws TimeoutException {
   try {
     // 等待线程
     if (!latch.await(timeout, unit)) {
       throw new TimeoutException("Command timed out");
     }
   } catch (InterruptedException e) {
     throw new RedisCommandInterruptedException(e);
   }
   return output.get();
 }