Package org.glassfish.grizzly

Examples of org.glassfish.grizzly.OutputSink


    }
   
    private NextAction flush(final FilterChainContext ctx) {
        final HttpContext httpContext = HttpContext.get(ctx);
        assert httpContext != null;
        final OutputSink output = httpContext.getOutputSink();

        if (output.canWrite()) {  // if connection write queue is not overloaded
            return ctx.getStopAction();
        } else { // if connection write queue is overloaded

            // 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


    }
   
    private NextAction flush(final FilterChainContext ctx) {
        final HttpContext httpContext = HttpContext.get(ctx);
        assert httpContext != null;
        final OutputSink output = httpContext.getOutputSink();

        if (output.canWrite()) {  // if connection write queue is not overloaded
            return ctx.getStopAction();
        } else { // if connection write queue is overloaded

            // 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

         * will block is dependent on the write timeout of the transport
         * associated with the specified connection.
         */
        private static void blockUntilQueueFree(final FilterChainContext ctx) {
            HttpContext httpContext = HttpContext.get(ctx);
            final OutputSink outputSink = httpContext.getOutputSink();
            if (!outputSink.canWrite()) {
                final FutureImpl<Boolean> future = Futures.createSafeFuture();
                outputSink.notifyCanWrite(new WriteHandler() {

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

         * {@inheritDoc}
         */
        @Override
        public synchronized void flush() throws IOException {
            final HttpContext httpContext = HttpContext.get(feedableBodyGenerator.context);
            final OutputSink outputSink = httpContext.getOutputSink();
            if (isReady()) {
                final boolean notReady = writeUntilFullOrDone(outputSink);
                if (!isDone()) {
                    if (notReady) {
                        notifyReadyToFeed(new ReadyToFeedListenerImpl());
                    } else {
                        // write queue is full, leverage WriteListener to let us know
                        // when it is safe to write again.
                        outputSink.notifyCanWrite(new WriteHandlerImpl());
                    }
                }
            } else {
                notifyReadyToFeed(new ReadyToFeedListenerImpl());
            }
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.OutputSink

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.