Thanks, Roland and √. My example was indeed made up (there are better
constructs in place) but thanks for clarifying that it's indeed the JVM
happens-before relations that applies.
– Kaspar
On Wednesday, September 21, 2016 at 12:56:41 AM UTC-7, √ wrote:
>
> Technically I think the solution
Technically I think the solution holds water, there are appropriate
barriers in place. (multi-materialization aside)
However, as mentioned, fold() would be a much cleaner, safer and
maintainable solution.
--
Cheers,
√
On Sep 21, 2016 07:05, "Roland Kuhn" wrote:
>
Technically I'm not sure this is correct: since f is only called from within a
single operator (and assuming only a single materialization) the shown code
should work just fine. Of course it is necessary to know what you're doing when
coding like this, and as Konrad says there are better
Thanks for clarifying, Konrad.
– Hbf
On Tuesday, September 20, 2016 at 4:33:53 PM UTC-7, Konrad Malawski wrote:
>
>
> final Source source = // ...
> final MutableInt max = new MutableInt(Integer.MIN_VALUE);
> final Procedure f = i -> {
> if (i >
final Source source = // ...
final MutableInt max = new MutableInt(Integer.MIN_VALUE);
final Procedure f = i -> {
if (i > max.intValue()) {
max.setValue(i);
}
};
final CompletionStage result = source
.runForeach(f, materializer)
Hey everybody,
Akka Stream may execute the function given to Source.runForEach() from
different threads. Therefore, if this function has state, it may need some
synchronization.
For example:
final Source source = // ...
final MutableInt max = new