Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.bolt.v1.packstream.PackOutput flush() throws java.io.IOException
        public override PackOutput Flush()
        {
            if (_buffer != null && _buffer.readableBytes() > 0)
            {
                CloseChunkIfOpen();

                // check for and apply write throttles
                try
                {
                    _throttleGroup.writeThrottle().acquire(_channel);
                }
                catch (TransportThrottleException ex)
                {
                    throw new BoltIOException(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidUsage, ex.Message, ex);
                }

                // Local copy and clear the buffer field. This ensures that the buffer is not re-released if the flush call fails
                ByteBuf @out = this._buffer;
                this._buffer = null;

                _channel.writeAndFlush(@out, _channel.voidPromise());

                _buffer = AllocateBuffer();
            }
            return(this);
        }