Java Code Examples for org.redisson.api.RCountDownLatch#await()

The following examples show how to use org.redisson.api.RCountDownLatch#await() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedissionUtilsTest.java    From Redis_Learning with Apache License 2.0 6 votes vote down vote up
/** 
     * ��Ϣ���еĶ����� 
     * @throws InterruptedException 
     */  
    @Test  
    public void testGetRTopicSub() throws InterruptedException {  
        RTopic<String> rTopic=RedissionUtils.getInstance().getRTopic(redisson, "testTopic");  
//        rTopic.addListener(new MessageListener<String>() {  
//
//			@Override
//			public void onMessage(String arg0, String arg1) {
//				System.out.println("�㷢������:"+arg0);
//			}  
//        });  
        //�ȴ������߷�����Ϣ  
        RCountDownLatch rCountDownLatch=RedissionUtils.getInstance().getRCountDownLatch(redisson, "testCountDownLatch");  
        rCountDownLatch.trySetCount(1);  
        rCountDownLatch.await();  
    }
 
Example 2
Source File: RedissionUtilsTest.java    From Redis_Learning with Apache License 2.0 5 votes vote down vote up
/** 
 * RCountDownLatch ӳ��Ϊredis server��string ���� 
 * string����ֵ 
 * ����--�ȴ������߳��еIJ��������� �ڽ��в��� 
 * �鿴���м�---->keys * 
 * �鿴key������--->type testCountDownLatch 
 * �鿴key��ֵ ---->get testCountDownLatch  
 */  
@Test  
public void testGetRCountDownLatch() throws InterruptedException {  
    RCountDownLatch rCountDownLatch=RedissionUtils.getInstance().getRCountDownLatch(redisson, "testCountDownLatch");  
    System.out.println(rCountDownLatch.getCount());  
    //rCountDownLatch.trySetCount(1l);  
    System.out.println(rCountDownLatch.getCount());  
    rCountDownLatch.await(10, TimeUnit.SECONDS);  
    System.out.println(rCountDownLatch.getCount());  
}
 
Example 3
Source File: RedissonCountDownLatchTest.java    From redisson with Apache License 2.0 4 votes vote down vote up
@Test
public void testCountDown() throws InterruptedException {
    RCountDownLatch latch = redisson.getCountDownLatch("latch");
    latch.trySetCount(2);
    Assert.assertEquals(2, latch.getCount());
    latch.countDown();
    Assert.assertEquals(1, latch.getCount());
    latch.countDown();
    Assert.assertEquals(0, latch.getCount());
    latch.await();
    latch.countDown();
    Assert.assertEquals(0, latch.getCount());
    latch.await();
    latch.countDown();
    Assert.assertEquals(0, latch.getCount());
    latch.await();

    RCountDownLatch latch1 = redisson.getCountDownLatch("latch1");
    latch1.trySetCount(1);
    latch1.countDown();
    Assert.assertEquals(0, latch.getCount());
    latch1.countDown();
    Assert.assertEquals(0, latch.getCount());
    latch1.await();

    RCountDownLatch latch2 = redisson.getCountDownLatch("latch2");
    latch2.trySetCount(1);
    latch2.countDown();
    latch2.await();
    latch2.await();

    RCountDownLatch latch3 = redisson.getCountDownLatch("latch3");
    Assert.assertEquals(0, latch.getCount());
    latch3.await();

    RCountDownLatch latch4 = redisson.getCountDownLatch("latch4");
    Assert.assertEquals(0, latch.getCount());
    latch4.countDown();
    Assert.assertEquals(0, latch.getCount());
    latch4.await();
}