and might there somehow miraculously be a way, at least in Scala, to
make it statically enforced?
The docs have a warning, but do not show a concrete example of the programming sin or why it is a sin.
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/kRtoHfgxJhAJ.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
Mike
Did you see the bottom of the link I posted? :-)
... and well you might have, Viktor. Would you please be more specific?
Mike
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+unsubscribe@googlegroups.com.
The docs have a warning, but do not show a concrete example of the programming sin or why it is a sin.
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/i_s2HnMbhy8J.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
implicit def future2actor[T](f: akka.dispatch.Future[T]) = new {def pipeTo(actor: ActorRef): this.type = {f onComplete {case Right(r) ⇒ actor ! rcase Left(f) ⇒ actor ! Status.Failure(f)}this}}
I wonder how it might be repurposed for Future.
3. Similar issues exist for closures in general. The problem exists for Java and Scala, and does not arise because of some property peculiar to Akka. Are you aware of some discussion on this subject?
Mike--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/MhlgCA-qqqkJ.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Patrik Nordwall
Typesafe - The software stack for applications that scale
Twitter: @patriknw
See Transactors. STM is only local though.
V
Any reason STM would not be a safe way to share mutable state?Mike
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/0u46RYK9StIJ.
1) In Jonas's 2009 JavaOne presentation he said: "My (humble) opinion on STM>Can never work fine in a language that don’t have compiler enforced immutability>E.g. never in Java (as of today)>Should not be used to “patch” Shared-State Concurrency>Still a research topic how to do it in imperative languages"His examples addressed Clojure's STM implementation. In general, is the current Akka STM implementation suitable
for accessing mutable state from Akka futures written in Scala and Java?2) The example code that I posted at the top of this thread shows a programming sin. In this limited context, is there any reason not to use STM?
Mike--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/YhYm6rBiItsJ.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
Mike
The point of the sinning example was that the state was a var, initially set to 6, then changed to 42. The resulting race condition caused an undesirable result. I am exploring various means of addressing the problem. STM is one such candidate.
Mike
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+unsubscribe@googlegroups.com.
This is still my base "religious" view of things. If you don't have
enforced immutability, and even better; an effect system, then it will
always be "correctness by convention". Which is less than ideal. But
my pragmatic view is that an STM in a language without this is still
very useful since it makes it much much easier to do the right thing
than walking in to the threads & locks war zone.
>
> His examples addressed Clojure's STM implementation. In general, is the
> current Akka STM implementation suitable for accessing mutable state from
> Akka futures written in Scala and Java?
>
> 2) The example code that I posted at the top of this thread shows a
> programming sin. In this limited context, is there any reason not to use
> STM?
>
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/akka-user/-/YhYm6rBiItsJ.
>
> To post to this group, send email to akka...@googlegroups.com.
> To unsubscribe from this group, send email to
> akka-user+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/akka-user?hl=en.
--
Jonas Bonér
CTO
Typesafe - The software stack for applications that scale
Phone: +46 733 777 123
Twitter: @jboner
--
Derek Williams
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
Take a look in twitter-util at com.twitter.util.SavedLocal, is this kind of what you are talking about Derek?
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/qQMf834agwQJ.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
So what is required is some way for each onComplete to call executorService.shutdown() after they have all started, or even better, after they have all finished; this pattern would facilitate the addition of more futures easily. Is a countdown latch the best approach?
You are right in a small program that fires off many futures and then stops, but a large program with collections of futures that serve different purposes would require something more substantial.Perhaps a trait that can be mixed in with Future that maintains a count singleton?
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/Yf8uEGaxJqcJ.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
You are right in a small program that fires off many futures and then stops, but a large program with collections of futures that serve different purposes would require something more substantial.Perhaps a trait that can be mixed in with Future that maintains a count singleton?
Roland,Very helpful information, thank you.
- Your example involved Actors, and a magical pipeTo solution. The biggest problem that I have encountered with regards to Actor scope issues is obtaining intermediate results from the top level actor back into the main program. Simulations and interactive games both exhibit this problem. For example, here is a little program that breaks the rules. How should it be reconstructed?
- Similar issues exist for Futures, but guidelines are scarce. Perhaps a pipeTo analog could be utilized? I found this definition of pipeTo in the source code:
implicit def future2actor[T](f: akka.dispatch.Future[T]) = new {def pipeTo(actor: ActorRef): this.type = {f onComplete {case Right(r) ⇒ actor ! rcase Left(f) ⇒ actor ! Status.Failure(f)}this}}I wonder how it might be repurposed for Future.
3. Similar issues exist for closures in general. The problem exists for Java and Scala, and does not arise because of some property peculiar to Akka. Are you aware of some discussion on this subject?
Thank you,Mike
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/MhlgCA-qqqkJ.