[akka-user] [akka-streams] Duplicator example from the docs

2014-12-29 Thread Adam Warski
Hello,

I'm reading through the streams docs, and I'm currently on the first 
Duplicator example 
(http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M2/scala/stream-customize.html)

I'm wondering if there are any guarantees on the order of calling onPush() 
and onPull()? For example, that onPush() won't be called twice in 
succession, but that onPush() and onPull calls are interleaved? Otherwise 
we may end up not duplicating elements (since we only remember the last 
one).

I guess this depends if there is any buffering around a custom 
push-pull-stage, but I would expect it to have a default buffer of awaiting 
elements?

Adam

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [akka-streams] Duplicator example from the docs

2015-01-01 Thread Akka Team
Hi Adam,

PushPull stage callbacks are never concurrent. Also, if a stage calls
ctx.Push then it will receive eventually an onPull, and whenever it calls
ctx.pull, it will receive an onPush eventually (of course completion events
can come at any time).

I'm wondering if there are any guarantees on the order of calling onPush()
> and onPull()? For example, that onPush() won't be called twice in
> succession, but that onPush() and onPull calls are interleaved? Otherwise
> we may end up not duplicating elements (since we only remember the last
> one).
>

You can imagine a series of stages like a pipe and a bouncing ball. When
receiving onPush() the ball just bounced into that segment of the pipe. If
you call ctx.push as a response to this, then the ball just continues
downwards. If you call ctx.pull, then it will bounce back upwards. There is
only one "ball" (unless you use DetachedOps but they are an advanced
concept).

Currently there is no exposed API to fuse multiple operations into such a
synchronous pipeline so all stages will run in a separate actor, but that
does not change their behavior (a single stage in an actor is actually
three stages, two boundary ones that talk to the actor, and your stage
sandwiched in-between) so the above mental model works.

These stages are completely unbuffered and there is only one activated
stage at a given time (in a given synchronous island).



>
> I guess this depends if there is any buffering around a custom
> push-pull-stage, but I would expect it to have a default buffer of awaiting
> elements?
>

There is never an implicit buffer there, unless you put your own explicit
buffering stage.

-Endre


>
> Adam
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] [akka-streams] Duplicator example from the docs

2015-01-06 Thread Adam Warski
Ok, if there's only one ball, that answers the question. Thanks! :)

Adam

On Thursday, January 1, 2015 10:00:27 AM UTC+1, Akka Team wrote:
>
> Hi Adam,
>
> PushPull stage callbacks are never concurrent. Also, if a stage calls 
> ctx.Push then it will receive eventually an onPull, and whenever it calls 
> ctx.pull, it will receive an onPush eventually (of course completion events 
> can come at any time).
>
> I'm wondering if there are any guarantees on the order of calling onPush() 
>> and onPull()? For example, that onPush() won't be called twice in 
>> succession, but that onPush() and onPull calls are interleaved? Otherwise 
>> we may end up not duplicating elements (since we only remember the last 
>> one).
>>
>
> You can imagine a series of stages like a pipe and a bouncing ball. When 
> receiving onPush() the ball just bounced into that segment of the pipe. If 
> you call ctx.push as a response to this, then the ball just continues 
> downwards. If you call ctx.pull, then it will bounce back upwards. There is 
> only one "ball" (unless you use DetachedOps but they are an advanced 
> concept).
>
> Currently there is no exposed API to fuse multiple operations into such a 
> synchronous pipeline so all stages will run in a separate actor, but that 
> does not change their behavior (a single stage in an actor is actually 
> three stages, two boundary ones that talk to the actor, and your stage 
> sandwiched in-between) so the above mental model works.
>
> These stages are completely unbuffered and there is only one activated 
> stage at a given time (in a given synchronous island).
>
>  
>
>>
>> I guess this depends if there is any buffering around a custom 
>> push-pull-stage, but I would expect it to have a default buffer of awaiting 
>> elements?
>>
>
> There is never an implicit buffer there, unless you put your own explicit 
> buffering stage.
>
> -Endre
>  
>
>>
>> Adam
>>
>> -- 
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Akka Team
> Typesafe - The software stack for applications that scale
> Blog: letitcrash.com
> Twitter: @akkateam
>  

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.