Examples of newPromise()


Examples of io.netty.channel.Channel.newPromise()

            return regFuture;
        }

        if (regFuture.isDone()) {
            // At this point we know that the registration was complete and succesful.
            ChannelPromise promise = channel.newPromise();
            doBind0(regFuture, channel, localAddress, promise);
            return promise;
        } else {
            // Registration future is almost always fulfilled already, but just in case it's not.
            final PendingRegistrationPromise promise = new PendingRegistrationPromise(channel);
View Full Code Here

Examples of io.netty.channel.ChannelHandlerContext.newPromise()

                    if (timeoutFuture != null) {
                        timeoutFuture.cancel(false);
                    }
                    engine.beginHandshake();
                    handshakePromises.add(promise);
                    flush0(ctx, ctx.newPromise(), true);
                } catch (Exception e) {
                    if (promise.tryFailure(e)) {
                        ctx.fireExceptionCaught(e);
                        ctx.close();
                    }
View Full Code Here

Examples of io.netty.channel.EventLoop.newPromise()

        });
    }

    public Future<Boolean> addAsync(final V value) {
        EventLoop loop = connectionManager.getGroup().next();
        final Promise<Boolean> promise = loop.newPromise();

        loop.execute(new Runnable() {
            @Override
            public void run() {
                try {
View Full Code Here

Examples of io.netty.channel.EventLoop.newPromise()

    }

    @Override
    public Future<Boolean> removeAsync(final V value) {
        EventLoop loop = connectionManager.getGroup().next();
        final Promise<Boolean> promise = loop.newPromise();

        loop.execute(new Runnable() {
            @Override
            public void run() {
                try {
View Full Code Here

Examples of io.netty.channel.EventLoop.newPromise()

                return eventLoop.newSucceededFuture(cachedResult.response.retain());
            } else {
                return eventLoop.newFailedFuture(cachedResult.cause);
            }
        } else {
            return query0(nameServerAddresses, question, eventLoop.<DnsResponse>newPromise());
        }
    }

    /**
     * Sends a DNS query with the specified question using the specified name server list.
View Full Code Here

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

    @SuppressWarnings("deprecation")
    public void testRegistrationAfterShutdown2() throws Exception {
        loopA.shutdown();
        final CountDownLatch latch = new CountDownLatch(1);
        Channel ch = new LocalChannel();
        ChannelPromise promise = ch.newPromise();
        promise.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                latch.countDown();
            }
View Full Code Here

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

        // start the eventloops
        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>();
View Full Code Here

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

        for (Queue<Long> timestamps : timestampsPerTask) {
            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.
View Full Code Here

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

        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() {
View Full Code Here

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

        assertTrue(f.cancel(true));
        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);
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.