You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "SirYwell (via GitHub)" <gi...@apache.org> on 2023/08/17 13:56:53 UTC

[GitHub] [incubator-pekko] SirYwell commented on issue #417: Avoid usage of `sun.misc.Unsafe`

SirYwell commented on issue #417:
URL: https://github.com/apache/incubator-pekko/issues/417#issuecomment-1682335651

   `VarHandle` could replace the usage of `Unsafe` pretty much 1:1. However, `VarHandle` is Java 9+.
   
   Looking at the usages, I'm wondering if much of it can be replaced by using `AtomicReference` instead. For example, consider https://github.com/apache/incubator-pekko/blob/3775a18c2eec1abd46355b656109f282d4115b40/actor/src/main/scala/org/apache/pekko/actor/RepointableActorRef.scala#L62-L80:
   
   To me, the tailrec methods look like overly complicated `getAndSet(...)` implementations, and `underlying` and `lookup` are just `get()`s.
   `Unsafe#getAndSetObject` was only added in Java 8, so I assume that's the reason it isn't used, but I'm not sure why the code doesn't make use of `AtomicReference`. Am I missing something?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org