Package io.netty.channel.local

Examples of io.netty.channel.local.LocalChannel.unsafe()


        loopA.execute(NOOP);
        loopB.execute(NOOP);

        LocalChannel channel = new LocalChannel();
        ChannelPromise registerPromise = channel.newPromise();
        channel.unsafe().register(loopA, registerPromise);
        registerPromise.sync();

        for (int i = 0; i < numtasks; i++) {
            Queue<Long> timestamps = new LinkedBlockingQueue<Long>();
            timestampsPerTask.add(timestamps);
View Full Code Here


            String message = String.format("size: %d, expected 0", timestamps.size());
            assertTrue(message, timestamps.isEmpty());
        }

        registerPromise = channel.newPromise();
        channel.unsafe().register(loopB, registerPromise);
        registerPromise.sync();

        // After the channel was registered with another eventloop the scheduled tasks should start executing again.
        // Same as above.
        Thread.sleep(50 + 10 * 100);
 
View Full Code Here

        LocalChannel channel = new LocalChannel();
        boolean firstRun = true;
        ScheduledFuture<?> f = null;
        while (i.incrementAndGet() < 4) {
            ChannelPromise registerPromise = channel.newPromise();
            channel.unsafe().register(i.intValue() % 2 == 0 ? loopA : loopB, registerPromise);
            registerPromise.sync();

            if (firstRun) {
                f = channel.eventLoop().scheduleAtFixedRate(new Runnable() {
                    @Override
View Full Code Here

        String message = String.format("size: %d, expected 0", timestamps.size());
        assertTrue(message, timestamps.isEmpty());

        // register again and check that it's not executed again.
        ChannelPromise registerPromise = channel.newPromise();
        channel.unsafe().register(loopA, registerPromise);
        registerPromise.sync();

        Thread.sleep(200);

        message = String.format("size: %d, expected 0", timestamps.size());
View Full Code Here

        loopA.execute(NOOP);
        loopB.execute(NOOP);

        LocalChannel channel = new LocalChannel();
        ChannelPromise registerPromise = channel.newPromise();
        channel.unsafe().register(loopA, registerPromise);
        registerPromise.sync();

        assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
        assertSame(loopA, channel.eventLoop().unwrap());
View Full Code Here

        String message = String.format("size: %d, expected 0", timestamps.size());
        assertTrue(message, timestamps.isEmpty());

        assertFalse(((PausableEventExecutor) channel.eventLoop()).isAcceptingNewTasks());
        registerPromise = channel.newPromise();
        channel.unsafe().register(loopB,  registerPromise);
        assertTrue(registerPromise.sync().isSuccess());
        assertTrue(((PausableEventExecutor) channel.eventLoop()).isAcceptingNewTasks());

        assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
        assertSame(loopB, channel.eventLoop().unwrap());
View Full Code Here

        loopA.execute(NOOP);
        loopB.execute(NOOP);

        LocalChannel channel = new LocalChannel();
        ChannelPromise registerPromise = channel.newPromise();
        channel.unsafe().register(loopA, registerPromise);
        registerPromise.sync();

        assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
        assertSame(loopA, ((PausableEventExecutor) channel.eventLoop()).unwrap());
View Full Code Here

        Thread.sleep(1000);

        registerPromise = channel.newPromise();
        assertFalse(oneTimeScheduledTaskExecuted.get());
        channel.unsafe().register(loopB, registerPromise);
        registerPromise.sync();

        assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
        assertSame(loopB, ((PausableEventExecutor) channel.eventLoop()).unwrap());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.