@@ -23,7 +23,7 @@ import org.apache.pekko
2323import pekko .actor ._
2424import pekko .annotation .InternalStableApi
2525import pekko .serialization .{ Serialization , SerializationExtension , Serializers }
26- import pekko .util .{ Helpers , Unsafe }
26+ import pekko .util .Helpers
2727
2828private [pekko] object Children {
2929 val GetNobody = () => Nobody
@@ -64,8 +64,7 @@ private[pekko] trait Children { this: ActorCell =>
6464
6565 @ nowarn @ volatile private var _functionRefsDoNotCallMeDirectly = Map .empty[String , FunctionRef ]
6666 private def functionRefs : Map [String , FunctionRef ] =
67- Unsafe .instance.getObjectVolatile(this , AbstractActorCell .functionRefsOffset).asInstanceOf [Map [String ,
68- FunctionRef ]]: @ nowarn(" cat=deprecation" )
67+ AbstractActorCell .functionRefsHandle.get(this ).asInstanceOf [Map [String , FunctionRef ]]
6968
7069 private [pekko] def getFunctionRefOrNobody (name : String , uid : Int = ActorCell .undefinedUid): InternalActorRef =
7170 functionRefs.getOrElse(name, Children .GetNobody ()) match {
@@ -84,8 +83,7 @@ private[pekko] trait Children { this: ActorCell =>
8483 @ tailrec def rec (): Unit = {
8584 val old = functionRefs
8685 val added = old.updated(childPath.name, ref)
87- if (! Unsafe .instance.compareAndSwapObject(this , AbstractActorCell .functionRefsOffset, old, added): @ nowarn(
88- " cat=deprecation" )) rec()
86+ if (! AbstractActorCell .functionRefsHandle.compareAndSet(this , old, added)) rec()
8987 }
9088 rec()
9189
@@ -100,8 +98,7 @@ private[pekko] trait Children { this: ActorCell =>
10098 if (! old.contains(name)) false
10199 else {
102100 val removed = old - name
103- if (! Unsafe .instance.compareAndSwapObject(this , AbstractActorCell .functionRefsOffset, old, removed): @ nowarn(
104- " cat=deprecation" )) rec()
101+ if (! AbstractActorCell .functionRefsHandle.compareAndSet(this , old, removed)) rec()
105102 else {
106103 ref.stop()
107104 true
@@ -112,9 +109,9 @@ private[pekko] trait Children { this: ActorCell =>
112109 }
113110
114111 protected def stopFunctionRefs (): Unit = {
115- val refs = Unsafe .instance
116- .getAndSetObject (this , AbstractActorCell .functionRefsOffset , Map .empty)
117- .asInstanceOf [Map [String , FunctionRef ]]: @ nowarn( " cat=deprecation " )
112+ val refs = AbstractActorCell .functionRefsHandle
113+ .getAndSet (this , Map .empty)
114+ .asInstanceOf [Map [String , FunctionRef ]]
118115 refs.valuesIterator.foreach(_.stop())
119116 }
120117
0 commit comments