I suspect your problem is that your test exits before the stream has a
chance to run.

On Thu, Apr 2, 2015 at 11:56 PM, Viktor Klang <viktor.kl...@gmail.com>
wrote:

> Works on my machine:
>
> scala> import scala.collection.mutable.ArrayBuffer
> import scala.collection.mutable.ArrayBuffer
>
> scala> import akka.stream._
> import akka.stream._
>
> scala> import akka.stream.scaladsl._
> import akka.stream.scaladsl._
>
> scala> implicit val sys = ActorSystem("repl")
> sys: akka.actor.ActorSystem = akka://repl
>
> scala> import sys.dispatcher
> import sys.dispatcher
>
> scala> implicit val fm = ActorFlowMaterializer()
> fm: akka.stream.ActorFlowMaterializer =
> ActorFlowMaterializerImpl(ActorFlowMaterializerSettings(4,16,,<function1>,StreamSubscriptionTimeoutSettings(CancelTermination,5000
> milliseconds),false,1000,Optimizations(false,false,false,false)),akka.dispatch.Dispatchers@3dff9cf6
> ,Actor[akka://repl/user/$b#575469743],1,flow,Optimizations(false,false,false,false))
>
> scala> val source: Source[Int, Unit] = Source(1 to 10)
> source: akka.stream.scaladsl.Source[Int,Unit] =
> akka.stream.scaladsl.Source@4d8aca2f
>
> scala> val printSink = Sink.foreach[Int](println)
> printSink: akka.stream.scaladsl.Sink[Int,scala.concurrent.Future[Unit]] =
> akka.stream.scaladsl.Sink@7d6cac88
>
>
> scala> val actionStream: ArrayBuffer[(Int) => Int] =
> ArrayBuffer.empty[(Int) => Int]
> actionStream: scala.collection.mutable.ArrayBuffer[Int => Int] =
> ArrayBuffer()
>
> scala> def add(a: Int) = a + 1
> add: (a: Int)Int
>
> scala>
>
> scala> def exec(): Unit =
>      |   actionStream.drop(1).foldLeft(source)(
>      |     (source, action) => source.via(Flow[Int].mapAsync(e =>
> Future(action(e))))
>      |   ).runWith(printSink)
> exec: ()Unit
>
> scala>
>
> scala> actionStream += add
> res6: actionStream.type = ArrayBuffer(<function1>)
>
> scala> actionStream += add
> res7: actionStream.type = ArrayBuffer(<function1>, <function1>)
>
> scala> exec()
>
> scala> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> 11
>
> On Thu, Apr 2, 2015 at 11:29 PM, Allen Nie <aiming...@gmail.com> wrote:
>
>> I came up a much simplified program to test, and I still get nothing:
>>
>> val source: Source[Int, Unit] = Source(1 to 10)
>> val printSink = Sink.foreach[Int](e => println(e))
>>
>> val actionStream: ArrayBuffer[(Int) => Int] = ArrayBuffer.empty[(Int) => Int]
>>
>> def add(a: Int) = a + 1
>>
>> def exec(): Unit = {
>>   val sourceReady = actionStream.drop(1).foldLeft(source)
>>   {(source, action) =>
>>     source.via(Flow[Int].mapAsync(e => Future(action.apply(e))))
>>   }
>>
>>   sourceReady
>>
>>   sourceReady.runWith(printSink)
>> }
>>
>> "parallel test" should "work" in {
>>   actionStream += ((a: Int) => add(a))
>>   actionStream += ((a: Int) => add(a))
>>
>>   exec()
>> }
>>
>>  --
>> >>>>>>>>>> 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.
>>
>
>
>
> --
> Cheers,
> √
>



-- 
Cheers,
√

-- 
>>>>>>>>>>      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.

Reply via email to