Examples of countDown()


Examples of java.util.concurrent.CountDownLatch.countDown()

        @Override
        public void run() {
          try {
            doSimpleGetRequest();
            latch.countDown();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

  public void timeoutTest() throws InterruptedException {
    long now = System.currentTimeMillis();
    final CountDownLatch latch = new CountDownLatch(5);
    final AsyncCallback cb = new AsyncCallback() {

      @Override public void onCallback() { latch.countDown(); }

    };

    Timeout t1 = new Timeout(now+1000, cb);
    Timeout t2 = new Timeout(now+1200, cb);
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

  @Test
  public void callbackTest() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(5);
    final AsyncCallback cb = new AsyncCallback() {

      @Override public void onCallback() { latch.countDown(); }
   
    };
    IOLoop.INSTANCE.addCallback(cb);
    IOLoop.INSTANCE.addCallback(cb);
    IOLoop.INSTANCE.addCallback(cb);
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

            for (String header : expectedHeaders) {
              assertTrue(response.getHeader(header) != null);
            }
            assertEquals(expectedPayload.length()+"", response.getHeader("Content-Length"));
          }
          latch.countDown();
          return response;
        }

        @Override
        public void onThrowable(Throwable t){
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

        assertEquals(200, response.getStatusCode());
        assertEquals("OK", response.getStatusText());
        assertEquals(5, response.getHeaders().size());
        String payLoad = response.getResponseBody();
        assertEquals(body, payLoad);
        latch.countDown();
        return response;
      }

      @Override
      public void onThrowable(Throwable t) { }
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

        assertEquals(200, response.getStatusCode());
        assertEquals("OK", response.getStatusText());
        assertEquals(5, response.getHeaders().size());
        String payLoad = response.getResponseBody();
        assertEquals(expectedBody, payLoad);
        latch.countDown();
        return response;
      }

      @Override
      public void onThrowable(Throwable t) { }
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

   
    final int n = 10;
    final CountDownLatch latch = new CountDownLatch(n);
    for (int i = 0; i < n; i++) {
      IOLoop.INSTANCE.addCallback(new AsyncCallback() { public void onCallback() { server.listen(PORT+1); }});
      IOLoop.INSTANCE.addCallback(new AsyncCallback() { public void onCallback() { server.stop(); latch.countDown(); }});
    }
    latch.await(5, TimeUnit.SECONDS);
    assertEquals(0, latch.getCount());
  }
 
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

        client.fetch(unresolvableAddress, new AsyncResult<org.deftserver.web.http.client.HttpResponse>() {

          public void onSuccess(org.deftserver.web.http.client.HttpResponse result) { client.close(); }

          public void onFailure(Throwable caught) {
            if (caught instanceof UnresolvedAddressException) latch.countDown();
            client.close();
          }
        });
      }
    };
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

        client.fetch(unconnectableAddress, new AsyncResult<org.deftserver.web.http.client.HttpResponse>() {

          public void onSuccess(org.deftserver.web.http.client.HttpResponse result) { client.close(); }

          public void onFailure(Throwable caught) {
            if (caught instanceof ConnectException) latch.countDown();
            client.close();
          }
        });
      }
    };
View Full Code Here

Examples of java.util.concurrent.CountDownLatch.countDown()

        new AsyncResult<org.deftserver.web.http.client.HttpResponse>() {

        public void onSuccess(org.deftserver.web.http.client.HttpResponse response) {
          result[0] = response.getBody();
          result[1] = response.getStatusLine();
          latch.countDown();
        }

        public void onFailure(Throwable ignore) { }
      };
      // make sure that the http.fetch(..) is invoked from the ioloop thread
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.