--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Is the program above deterministic?
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Roland, thanks! - again you have caught my intention :) Thanks for the clarification, will try to wrap a Future with something appropriate.
Indeed that matching case is silly as far as it doesn't fit to 'result' signature.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
The rule is: Only ever use Await.<X> if you _must_ go from Future[T] => T.
99% of the times otherwise there is a cheaper, more performant and less buggy solution using the combinators.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Please share an example of that loss?
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
What does the iteratee do when the Future is failed?
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Try { fuA.flatMap( w(_, e)) } match {
case Success(fu) => Cont[Array[Byte], Future[A]](newIn => step(fu)(newIn))
case Failure(err) => Error(err.getMessage, Input.EOF)
}
Could you explain this piece of code?
On Tuesday, May 21, 2013 9:34:57 PM UTC+4, √iktor Klang wrote:Try { fuA.flatMap( w(_, e)) } match {
case Success(fu) => Cont[Array[Byte], Future[A]](newIn => step(fu)(newIn))
case Failure(err) => Error(err.getMessage, Input.EOF)
w() is that consuming function which takes a current state (the first parameter of type A) and the next chunk of bytes (the second parameter) and calculates next expected state in async manner returning next state in Future[A]. At some error I rise exception in w() implementation and want to return to feeder an error (iteratee builder Error()) instead of a law how to execute iteration step (iteratee builder Cont). Last one takes Future[A] as argument.
}
Could you explain this piece of code?
OTOH w() takes A, but we have Future[A] in hand (previous state). So, to call w() we use flatMap. But with flatMap we can not catch the exception thrown in w() with Try.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Try { fuA.flatMap( w(_, e)) } match {case Success(fu) => Cont[Array[Byte], Future[A]](newIn => step(fu)(newIn))When is ``w(_, e)`` executed and on which thread?
case Failure(err) => Error(err.getMessage, Input.EOF)When can this branch be taken?
Exactly, so the Failure branch will never be taken, since it will always be a ``Success(fu)``
James, heartily thanks! Have tried your suggestion with flatten and recover. Both work as expected, malicious uploading is interrupting almost immediately. fold1 also works at legal mainstream case, but doesn't suit for immediate interrupting.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.