Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Reactive Streams

Hi,

On Tue, Jun 2, 2015 at 4:22 PM, Greg Wilkins <gregw@xxxxxxxxxxx> wrote:
> But my fragmentor does modify decrement demand.  Demand in this case is help
> by the counting semaphore and it is acquired in the loop.  So in my case if
> there is no demand the fragmenter blocks.  I'll rename the semaphone to
> demand!
>
> You are suggesting it saves the buffer, but that is not a general solution
> as it may have been passed a 4GB memory mapped buffer and thus cannot save
> it to memory!

I don't understand why you say this.
If a Servlet passes a 4 GiB memory mapped buffer to Jetty, currently,
we do it right.
We can do it right here too.

>> I'm not sure I follow your last point about close().
>> If you have stuff to send, then close() should first call onNext()
>> with what remains to send (and only if it has demand), and when it's
>> called back with a request(int) to signal more demand, it can call
>> onComplete().
>
>
> Exactly!   So if you are a Processor and onComplete is called on you, you
> have to wait for demand so that you can flush your buffers.  onComplete will
> thus be a blocking call!

When you say "if you are a Processor and onComplete() is called on
you, you have to wait for demand", you are getting it the other way
around.

Method onComplete() is not called until there is demand.
Since there is demand, you don't block.

It's a pull model, so the last stage is the one that drives the previous stage.
Callbacks on the last stage don't happen unless it has signalled demand.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top