Package co.paralleluniverse.fibers

Examples of co.paralleluniverse.fibers.Fiber


    }

    @Test
    public void testMerge2() {
        try {
            Fiber c = new Fiber((String)null, null, new Merge2Test());
            TestsHelper.exec(c);
            assertTrue("Should not reach here", false);
        } catch (NullPointerException ex) {
            // NPE expected
        }
View Full Code Here


    }

    @Test
    public void testAnnotated() {
        try {
            Fiber co = new Fiber((String) null, null, (SuspendableCallable) null) {
                @Override
                protected Object run() throws SuspendExecution, InterruptedException {
                    suspendableMethod();
                    return null;
                }
View Full Code Here

    }

    @Test
    public void testNonAnnotated() {
        try {
            Fiber co = new Fiber((String) null, null, (SuspendableCallable) null) {
                @Override
                protected Object run() throws SuspendExecution, InterruptedException {
                    nonsuspendableMethod();
                    return null;
                }
View Full Code Here

    @Test
    public void testFinally() {
        results.clear();
       
        try {
            Fiber co = new Fiber((String)null, null, this);
            exec(co);
            results.add("B");
            exec(co);
            results.add("D");
            exec(co);
View Full Code Here

    private EventSourceActor<String> spawnGenEvent(Initializer initializer) {
        return spawnActor(new EventSourceActor<String>(initializer));
    }

    private <T extends Actor<Message, V>, Message, V> T spawnActor(T actor) {
        Fiber fiber = new Fiber(actor);
        fiber.setUncaughtExceptionHandler(new Strand.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Strand s, Throwable e) {
                e.printStackTrace();
                throw Exceptions.rethrow(e);
            }
        });
        fiber.start();
        return actor;
    }
View Full Code Here

*/
public class SuspendTest implements SuspendableRunnable {
    @Test
    public void testSuspend() {
        SuspendTest test = new SuspendTest();
        Fiber co = new Fiber((String)null, null, test);

        while (!exec(co))
            System.out.println("State=" + co.getState());

        System.out.println("State=" + co.getState());
    }
View Full Code Here

        for (int i = 0; i < 10; i++)
            new RingBenchmark().run();
    }

    private static <Message, V> Actor<Message, V> spawnActor(Actor<Message, V> actor) {
        new Fiber(actor).start();
        return actor;
    }
View Full Code Here

    }

    @Test
    public void testSuspend() {
//    final I i = new C();
        Fiber co = new Fiber((String)null, null, new SuspendableRunnable() {
            @Override
            public final void run() throws SuspendExecution {
                // next line causes an error because of incomplete merge in TypeInterpreter
                //SomeInterface i = System.currentTimeMillis() > 0 ? new C() : new C2();
                SomeInterface i = new C();
                System.out.println("i = " + i);
                i.doStuff();
            }
        });
        while (!TestsHelper.exec(co))
            System.out.println("State=" + co.getState());
        System.out.println("State=" + co.getState());
    }
View Full Code Here

    @Test
    public void testCatch() {
        results.clear();

        try {
            Fiber co = new Fiber((String) null, null, new Runnable1());
            exec(co);
            results.add("B");
            exec(co);
            results.add("D");
            exec(co);
View Full Code Here

    @Test
    public void testCatch2() {
        results.clear();

        try {
            Fiber co = new Fiber((String) null, null, new Callable1());
            exec(co);
            results.add("B");
            exec(co);
            results.add("D");
            exec(co);
View Full Code Here

TOP

Related Classes of co.paralleluniverse.fibers.Fiber

Copyright © 2018 www.massapicom. 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.