Search in sources :

Example 6 with Fiber

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

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

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

Example 9 with Fiber

use of co.paralleluniverse.fibers.Fiber in project quasar by puniverse.

the class InstrumentationOptimizerTest method testSkipForwardsToSuspendableDouble.

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

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

Example 10 with Fiber

use of co.paralleluniverse.fibers.Fiber in project quasar by puniverse.

the class TransferSelectorTest method testSelectSendWithClose2.

@Test
public void testSelectSendWithClose2() throws Exception {
    final Channel<String> channel1 = newChannel();
    final Channel<String> channel2 = newChannel();
    final Channel<String> channel3 = newChannel();
    Fiber fib = new Fiber("fiber", scheduler, new SuspendableRunnable() {

        @Override
        public void run() throws SuspendExecution, InterruptedException {
            Strand.sleep(200);
            SelectAction<String> sa1 = select(send(channel1, "hi1"), send(channel2, "hi2"), send(channel3, "hi3"));
            Strand.sleep(200);
            SelectAction<String> sa2 = select(send(channel1, "hi1"), send(channel2, "hi2"), send(channel3, "hi3"));
            assertThat(sa1.index(), is(1));
            assertThat(sa2.index(), is(1));
        }
    }).start();
    channel2.close();
    fib.join();
}
Also used : SuspendableRunnable(co.paralleluniverse.strands.SuspendableRunnable) Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Aggregations

Fiber (co.paralleluniverse.fibers.Fiber)103 Test (org.junit.Test)86 SuspendableRunnable (co.paralleluniverse.strands.SuspendableRunnable)73 SuspendExecution (co.paralleluniverse.fibers.SuspendExecution)19 Strand (co.paralleluniverse.strands.Strand)8 QueueCapacityExceededException (co.paralleluniverse.strands.queues.QueueCapacityExceededException)4 IntChannel (co.paralleluniverse.strands.channels.IntChannel)3 ExecutionException (java.util.concurrent.ExecutionException)3 Ignore (org.junit.Ignore)3 Timeout (co.paralleluniverse.strands.Timeout)2 Channel (co.paralleluniverse.strands.channels.Channel)2 ReceivePort (co.paralleluniverse.strands.channels.ReceivePort)2 ActorRef (co.paralleluniverse.actors.ActorRef)1 AbstractServerHandler (co.paralleluniverse.actors.behaviors.AbstractServerHandler)1 ServerActor (co.paralleluniverse.actors.behaviors.ServerActor)1 Function2 (co.paralleluniverse.common.util.Function2)1 Pair (co.paralleluniverse.common.util.Pair)1 FiberScheduler (co.paralleluniverse.fibers.FiberScheduler)1 FiberWriter (co.paralleluniverse.fibers.FiberWriter)1 VerifyInstrumentationException (co.paralleluniverse.fibers.VerifyInstrumentationException)1