Search in sources :

Example 11 with SuspendableRunnable

use of co.paralleluniverse.strands.SuspendableRunnable in project quasar by puniverse.

the class InheritTest method testInherit.

@Test
public void testInherit() {
    final C dut = new C();
    Fiber c = new Fiber((String) null, null, new SuspendableRunnable() {

        @Override
        public void run() throws SuspendExecution {
            dut.myMethod();
        }
    });
    for (int i = 0; i < 3; i++) {
        exec(c);
    }
    assertEquals(5, dut.result.size());
    assertEquals("a", dut.result.get(0));
    assertEquals("o1", dut.result.get(1));
    assertEquals("o2", dut.result.get(2));
    assertEquals("b", dut.result.get(3));
    assertEquals("b", dut.result.get(4));
}
Also used : SuspendExecution(co.paralleluniverse.fibers.SuspendExecution) SuspendableRunnable(co.paralleluniverse.strands.SuspendableRunnable) Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Example 12 with SuspendableRunnable

use of co.paralleluniverse.strands.SuspendableRunnable in project quasar by puniverse.

the class InstrumentationOptimizerTest method testDontSkipForwardsWithReflectiveCalls.

@Test
public void testDontSkipForwardsWithReflectiveCalls() throws InterruptedException, SuspendExecution, ExecutionException {
    new Fiber(new SuspendableRunnable() {

        @Override
        public void run() throws SuspendExecution, InterruptedException {
            try {
                dontSkipForwardsWithReflectiveCalls();
            } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
                throw new RuntimeException(ex);
            }
        }
    }).start().join();
    assertFalse(isOptimized("skipForwardsWithReflectiveCalls"));
}
Also used : SuspendExecution(co.paralleluniverse.fibers.SuspendExecution) SuspendableRunnable(co.paralleluniverse.strands.SuspendableRunnable) Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Example 13 with SuspendableRunnable

use of co.paralleluniverse.strands.SuspendableRunnable in project quasar by puniverse.

the class InstrumentationOptimizerTest method testSkipForwardsToSuspendableObject.

@Test
public void testSkipForwardsToSuspendableObject() throws InterruptedException, SuspendExecution, ExecutionException {
    new Fiber(new SuspendableRunnable() {

        @Override
        public void run() throws SuspendExecution, InterruptedException {
            skipForwardsToSuspendableObject();
        }
    }).start().join();
    assertTrue(isOptimized("skipForwardsToSuspendableObject"));
}
Also used : SuspendExecution(co.paralleluniverse.fibers.SuspendExecution) SuspendableRunnable(co.paralleluniverse.strands.SuspendableRunnable) Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Example 14 with SuspendableRunnable

use of co.paralleluniverse.strands.SuspendableRunnable in project quasar by puniverse.

the class InstrumentationOptimizerTest method testSkipForwardsToSuspendableFloat.

@Test
public void testSkipForwardsToSuspendableFloat() throws InterruptedException, SuspendExecution, ExecutionException {
    new Fiber(new SuspendableRunnable() {

        @Override
        public void run() throws SuspendExecution, InterruptedException {
            skipForwardsToSuspendableFloat();
        }
    }).start().join();
    assertTrue(isOptimized("skipForwardsToSuspendableFloat"));
}
Also used : SuspendExecution(co.paralleluniverse.fibers.SuspendExecution) SuspendableRunnable(co.paralleluniverse.strands.SuspendableRunnable) Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Example 15 with SuspendableRunnable

use of co.paralleluniverse.strands.SuspendableRunnable in project quasar by puniverse.

the class InstrumentationOptimizerTest method testSkipForwardsToSuspendableVoid.

@Test
public void testSkipForwardsToSuspendableVoid() throws InterruptedException, SuspendExecution, ExecutionException {
    new Fiber(new SuspendableRunnable() {

        @Override
        public void run() throws SuspendExecution, InterruptedException {
            skipForwardsToSuspendableVoid();
        }
    }).start().join();
    assertTrue(isOptimized("skipForwardsToSuspendableVoid"));
}
Also used : SuspendExecution(co.paralleluniverse.fibers.SuspendExecution) SuspendableRunnable(co.paralleluniverse.strands.SuspendableRunnable) Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Aggregations

SuspendableRunnable (co.paralleluniverse.strands.SuspendableRunnable)90 Test (org.junit.Test)82 Fiber (co.paralleluniverse.fibers.Fiber)73 SuspendExecution (co.paralleluniverse.fibers.SuspendExecution)22 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 Strand (co.paralleluniverse.strands.Strand)4 QueueCapacityExceededException (co.paralleluniverse.strands.queues.QueueCapacityExceededException)4 ExecutionException (java.util.concurrent.ExecutionException)4 Ignore (org.junit.Ignore)3 Condition (co.paralleluniverse.strands.Condition)2 SimpleConditionSynchronizer (co.paralleluniverse.strands.SimpleConditionSynchronizer)2 Timeout (co.paralleluniverse.strands.Timeout)2 Channel (co.paralleluniverse.strands.channels.Channel)2 IntChannel (co.paralleluniverse.strands.channels.IntChannel)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CheckedCallable (co.paralleluniverse.common.util.CheckedCallable)1 Function2 (co.paralleluniverse.common.util.Function2)1 Pair (co.paralleluniverse.common.util.Pair)1 VerifyInstrumentationException (co.paralleluniverse.fibers.VerifyInstrumentationException)1