Package io.netty.channel.local

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


        registerPromise.sync();

        for (int i = 0; i < numtasks; i++) {
            Queue<Long> timestamps = new LinkedBlockingQueue<Long>();
            timestampsPerTask.add(timestamps);
            scheduledFutures.add(channel.eventLoop()
                    .scheduleAtFixedRate(new TimestampsRunnable(timestamps), 0, 100, TimeUnit.MILLISECONDS));
        }

        // Each task should be executed every 100ms.
        // Will give them additional 50ms to execute ten times.
View Full Code Here


            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
                    public void run() {
                        assertTrue((i.intValue() % 2 == 0 ? loopA : loopB).inEventLoop());
                        timestamps.add(System.nanoTime());
                    }
View Full Code Here

        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());

        ScheduledFuture<?> scheduleFuture;
        if (PeriodicScheduleMethod.FIXED_RATE == method) {
            scheduleFuture = channel.eventLoop().scheduleAtFixedRate(new Runnable() {
View Full Code Here

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

        assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
        assertSame(loopA, channel.eventLoop().unwrap());

        ScheduledFuture<?> scheduleFuture;
        if (PeriodicScheduleMethod.FIXED_RATE == method) {
            scheduleFuture = channel.eventLoop().scheduleAtFixedRate(new Runnable() {
                @Override
View Full Code Here

        assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
        assertSame(loopA, channel.eventLoop().unwrap());

        ScheduledFuture<?> scheduleFuture;
        if (PeriodicScheduleMethod.FIXED_RATE == method) {
            scheduleFuture = channel.eventLoop().scheduleAtFixedRate(new Runnable() {
                @Override
                public void run() {
                    assertTrue(loopB.inEventLoop());
                    timestamps.add(System.nanoTime());
                }
View Full Code Here

                    assertTrue(loopB.inEventLoop());
                    timestamps.add(System.nanoTime());
                }
            }, 100, 200, TimeUnit.MILLISECONDS);
        } else {
            scheduleFuture = channel.eventLoop().scheduleWithFixedDelay(new Runnable() {
                @Override
                public void run() {
                    assertTrue(loopB.inEventLoop());
                    timestamps.add(System.nanoTime());
                }
View Full Code Here

                    timestamps.add(System.nanoTime());
                }
            }, 100, 200, TimeUnit.MILLISECONDS);
        }

        assertTrue(((PausableEventExecutor) channel.eventLoop()).isAcceptingNewTasks());
        ChannelFuture deregisterFuture = channel.deregister();
        assertFalse(((PausableEventExecutor) channel.eventLoop()).isAcceptingNewTasks());

        assertTrue(deregisterFuture.sync().isSuccess());
View Full Code Here

            }, 100, 200, TimeUnit.MILLISECONDS);
        }

        assertTrue(((PausableEventExecutor) channel.eventLoop()).isAcceptingNewTasks());
        ChannelFuture deregisterFuture = channel.deregister();
        assertFalse(((PausableEventExecutor) channel.eventLoop()).isAcceptingNewTasks());

        assertTrue(deregisterFuture.sync().isSuccess());

        timestamps.clear();
        Thread.sleep(1000);
View Full Code Here

        // no scheduled tasks must be executed after deregistration.
        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());
View Full Code Here

        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());

        // 100ms internal delay + 1 second. Should be able to execute 5 tasks in that time.
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.