This is not safe, outbound and inbound flows could be executing on different threads. It's not a question about the the DSL being safe - that's fine as it's only constructing stuff, but the graph you constructed is accessing shared state from (potentially) different threads - thus it is not safe.
-- Konrad `ktoso` Malawski Akka <http://akka.io> @ Lightbend <http://lightbend.com> On 19 October 2016 at 13:24:50, Alexey Shuksto (seig...@gmail.com) wrote: Hello hAkkers, Simple example: val zipper = BidiFlow.fromGraph(GraphDSL.create() { b => var counter = 0 val outbound = b.add(Flow[String].map { str => counter += 1 str -> counter }) val inbound = b.add(Flow[(String, Int)].map { pair => counter -= 1 pair._1 }) BidiShape.fromFlows(outbound, inbound) }) Can I presume that contents of 'build block' is thread-safe or I need to guard `counter` somehow (use `AtomicInt` and such)? Also, do BidiFlow support 'duplex' mode or they process incoming/outgoing messages one at time? -- >>>>>>>>>> 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 https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- >>>>>>>>>> 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 https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.