Hi Greg,

you are right about not using Thread.sleep() as that would render a thread
unavailable for other tasks. After a couple of such flows are run whole
stream pipeline would freeze.

You can achieve your desired effect with a little custom GraphStage. Such a
stage might have an input and an output for the regular elements to go
through and one additional input that would be used to control the flow. Here
is my quick attempt
<https://github.com/2m/akka-stream-sandbox/blob/209c2bb4bef2d7d35f88c27d6e7cfccc9eea33be/src/main/scala/FlowLatch.scala#L25>
at such an GraphStage.

On Tue, Dec 1, 2015 at 7:14 PM, tigerfoot <[email protected]> wrote:

> Hello,
>
> I need a way to toggle a flow on/off (i.e. pause a flow).  I created this
> simple thing in the DLS:
>
>   val throttle = Flow[Int].map(i => {while(!toggle) Thread.sleep(100);
> i})
>
>
> This works as I need it when I use it in a FlowGraph, but I hate the
> sleep.  Before I go off the tracks with some Promise-based thing, is there
> a better way to accomplish what I'm trying to do?
>
>
> Greg
>
> --
> >>>>>>>>>> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Martynas Mickevičius
Typesafe <http://typesafe.com/> – Reactive
<http://www.reactivemanifesto.org/> Apps on the JVM

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to