Package org.glassfish.grizzly

Examples of org.glassfish.grizzly.WriteHandler


        @Override
        public boolean isValid() {
            if (!connection.canWrite()) {
                try {
                    connection.notifyCanWrite(new WriteHandler() {
                        @Override
                        public void onWritePossible() throws Exception {
                            taskProcessor.processTask();
                        }
View Full Code Here


            // prepare context for suspend
            final NextAction suspendAction = ctx.getSuspendAction();
            ctx.suspend();

            // notify when connection becomes writable, so we can resume it
            output.notifyCanWrite(new WriteHandler() {
                @Override
                public void onWritePossible() throws Exception {
                    finish();
                }
View Full Code Here

    /**
     * Notify WriteHandler
     */
    private void notifyWritePossible() {
        final WriteHandler localHandler = handler;

        if (localHandler != null) {
            final Reentrant reentrant = Reentrant.getWriteReentrant();
           
            try {
                handler = null;
                reentrant.inc();

                isNonBlockingWriteGuaranteed = true;

                localHandler.onWritePossible();
            } catch (Throwable t) {
                localHandler.onError(t);
            } finally {
                reentrant.dec();
            }
        }
    }
View Full Code Here

            return;
        }
       
        final FutureImpl<Boolean> future = Futures.createSafeFuture();
       
        httpContext.getOutputSink().notifyCanWrite(new WriteHandler() {

            @Override
            public void onWritePossible() throws Exception {
                future.result(Boolean.TRUE);
            }
View Full Code Here

            } catch (Exception ignored) {
            }
        }

        private static void onError0(final OutputBuffer ob, final Throwable t) {
            final WriteHandler localHandler = ob.handler;

            if (localHandler != null) {
                try {
                    ob.handler = null;
                    localHandler.onError(t);
                } catch (Exception ignored) {
                }
            }
        }
View Full Code Here

        }
       
        final int maxQueueSize = maxQueueSizeHolder.getMaxQueueSize();
       
        while(spaceInBytes() <= maxQueueSize) {
            WriteHandler writeHandler = pollWriteHandler();
            if (writeHandler == null) {
                return;
            }
           
            try {
                writeHandler.onWritePossible();
            } catch (Throwable e) {
                writeHandler.onError(e);
            }
        }
    }
View Full Code Here

            while ((record = poll()) != null) {
                record.notifyFailure(error);
            }
        }
       
        WriteHandler writeHandler;
        while ((writeHandler = pollWriteHandler()) != null) {
            if (error == null) {
                error = new IOException("Connection closed", cause);
            }
            writeHandler.onError(error);
        }
    }
View Full Code Here

       
        return false;
    }

    private WriteHandler pollWriteHandler() {
        final WriteHandler record = writeHandlersQueue.poll();
        if (record != null) {
            writeHandlersCounter.decrementAndGet();
            return record;
        }
       
View Full Code Here

    /**
     * Notify WriteHandler
     */
    private void notifyWritePossible() {
        final WriteHandler localHandler = handler;

        if (localHandler != null) {
            final Reentrant reentrant = Reentrant.getWriteReentrant();
           
            try {
                handler = null;
                reentrant.inc();

                isNonBlockingWriteGuaranteed = true;

                localHandler.onWritePossible();
            } catch (Throwable t) {
                localHandler.onError(t);
            } finally {
                reentrant.dec();
            }
        }
    }
View Full Code Here

            return;
        }
       
        final FutureImpl<Boolean> future = Futures.createSafeFuture();
       
        httpContext.getOutputSink().notifyCanWrite(new WriteHandler() {

            @Override
            public void onWritePossible() throws Exception {
                future.result(Boolean.TRUE);
            }
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.WriteHandler

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.