Package java.util.concurrent

Examples of java.util.concurrent.Semaphore.acquire()


        }

        LOG.info("Sample done.");
        sampleTimeDone.countDown();

        workerDone.acquire();
        if (workerError[0] != null) {
            throw workerError[0];
        }
    }
}
View Full Code Here


      }
    });
    subscriberClient.subscribe("test");
    RedisClient.Pipeline publisherClient = new RedisClient("localhost", 6379).pipeline();
    for (int i = 0; i < CALLS * 10; i++) {
      semaphore.acquire();
      SettableFuture<Object> future = SettableFuture.create();
      futureRef.set(future);
      publisherClient.publish(test, hello);
    }
    semaphore.acquire(50);
View Full Code Here

      semaphore.acquire();
      SettableFuture<Object> future = SettableFuture.create();
      futureRef.set(future);
      publisherClient.publish(test, hello);
    }
    semaphore.acquire(50);
    long end = System.currentTimeMillis();
    System.out.println("Pub/sub pipelined: " + (CALLS * 10 * 1000) / (end - start) + " calls per second");
  }

}
View Full Code Here

              redisClient.execute(title, command);
              long commandend = System.nanoTime();
              int bin = (int) ((commandend - commandstart) / NANOS_PER_MILLI);
              bins.get(bin).incrementAndGet();
            } else {
              semaphore.acquire(1);
              ListenableFuture<? extends Reply> pipeline = redisClient.pipeline(title, command);
              pipeline.addListener(new Runnable() {
                @Override
                public void run() {
                  long commandend = System.nanoTime();
View Full Code Here

                  semaphore.release();
                }
              }, es);
            }
          }
          semaphore.acquire(P);
          redisClient.close();
          return null;
        }
      });
    }
View Full Code Here

    if (System.getenv().containsKey("CI") || System.getProperty("CI") != null) return;
    long start = System.currentTimeMillis();
    RedisClientBase client = connect("localhost", 6379).get();
    final Semaphore semaphore = new Semaphore(100);
    for (int i = 0; i < CALLS; i++) {
      semaphore.acquire();
      client.send(new Command("SET", Encoding.numToBytes(i), "value")).ensure(new Runnable() {
        @Override
        public void run() {
          semaphore.release();
        }
View Full Code Here

        public void run() {
          semaphore.release();
        }
      });
    }
    semaphore.acquire(50);
    System.out.println("Netty4 pipelined: " + CALLS  * 1000 / (System.currentTimeMillis() - start));
  }
}
View Full Code Here

                  semaphore.release();
                }
              };
              long start = System.currentTimeMillis();
              while (System.currentTimeMillis() - start < 5000) {
                semaphore.acquire();
                String current = String.valueOf(total.getAndIncrement());
                redisClient.set(current, current).ensure(release);
              }
              semaphore.acquire(100);
              done.countDown();
View Full Code Here

              while (System.currentTimeMillis() - start < 5000) {
                semaphore.acquire();
                String current = String.valueOf(total.getAndIncrement());
                redisClient.set(current, current).ensure(release);
              }
              semaphore.acquire(100);
              done.countDown();
            } catch (InterruptedException e) {
              e.printStackTrace();
            }
          }
View Full Code Here

                  semaphore.release();
                }
              };
              long start = System.currentTimeMillis();
              while (System.currentTimeMillis() - start < 5000) {
                semaphore.acquire();
                final String current = String.valueOf(total.getAndIncrement());
                redisClient.set(current, current).ensure(release).onSuccess(new Block<StatusReply>() {
                  @Override
                  public void apply(StatusReply statusReply) {
                    redisClient.get(current).onSuccess(new Block<BulkReply>() {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.