Search in sources :

Example 6 with SuspendExecution

use of co.paralleluniverse.fibers.SuspendExecution 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 7 with SuspendExecution

use of co.paralleluniverse.fibers.SuspendExecution 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 8 with SuspendExecution

use of co.paralleluniverse.fibers.SuspendExecution 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 9 with SuspendExecution

use of co.paralleluniverse.fibers.SuspendExecution 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 10 with SuspendExecution

use of co.paralleluniverse.fibers.SuspendExecution 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

SuspendExecution (co.paralleluniverse.fibers.SuspendExecution)40 Test (org.junit.Test)30 SuspendableRunnable (co.paralleluniverse.strands.SuspendableRunnable)24 Fiber (co.paralleluniverse.fibers.Fiber)20 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 Suspendable (co.paralleluniverse.fibers.Suspendable)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 Strand (co.paralleluniverse.strands.Strand)3 ArrayList (java.util.ArrayList)3 TimeoutException (java.util.concurrent.TimeoutException)3 Channel (co.paralleluniverse.strands.channels.Channel)2 ExecutionException (java.util.concurrent.ExecutionException)2 Matchers.anyObject (org.mockito.Matchers.anyObject)2 Actor (co.paralleluniverse.actors.Actor)1 ActorRef (co.paralleluniverse.actors.ActorRef)1 BasicActor (co.paralleluniverse.actors.BasicActor)1 LocalActor (co.paralleluniverse.actors.LocalActor)1 MailboxConfig (co.paralleluniverse.actors.MailboxConfig)1 MessageProcessor (co.paralleluniverse.actors.MessageProcessor)1 AbstractServerHandler (co.paralleluniverse.actors.behaviors.AbstractServerHandler)1