@@ -184,6 +184,26 @@ trait Node extends ClusterListener with ClusterPublisher {
184184 def timer : HashedWheelTimer
185185}
186186
187+ object ErlangNode {
188+
189+ def newConcurrentMap [K ,V ](config : NodeConfig ): ConcurrentMap [K ,V ] = {
190+ if (config.useNBHM) {
191+ new NonBlockingHashMap [K ,V ]
192+ } else {
193+ new ConcurrentHashMap [K ,V ]
194+ }
195+ }
196+
197+ def newAtomicMap [K ,V ](config : NodeConfig ): AtomicMap [K ,V ] = {
198+ if (config.useNBHM) {
199+ AtomicMap .atomicNBHM[K ,V ]
200+ } else {
201+ AtomicMap .atomicCHM[K ,V ]
202+ }
203+ }
204+
205+ }
206+
187207class ErlangNode (val name : Symbol , val cookie : String , config : NodeConfig ) extends Node
188208 with ExitListener
189209 with SendListener
@@ -198,11 +218,11 @@ class ErlangNode(val name : Symbol, val cookie : String, config : NodeConfig) ex
198218 val tickTime = config.tickTime
199219 val poolFactory = config.poolFactory
200220 var creation : Int = 0
201- val processes = new NonBlockingHashMap [Pid ,ProcessAdapter ]
202- val registeredNames = new NonBlockingHashMap [Symbol ,Pid ]
203- val channels = AtomicMap .atomicNBHM [Symbol ,Channel ]
204- val links = AtomicMap .atomicNBHM [Channel ,NonBlockingHashSet [Link ]]
205- val monitors = AtomicMap .atomicNBHM [Channel ,NonBlockingHashSet [Monitor ]]
221+ val processes = ErlangNode .newConcurrentMap [Pid ,ProcessAdapter ](config)
222+ val registeredNames = ErlangNode .newConcurrentMap [Symbol ,Pid ](config)
223+ val channels = ErlangNode .newAtomicMap [Symbol ,Channel ](config)
224+ val links = ErlangNode .newAtomicMap [Channel ,NonBlockingHashSet [Link ]](config)
225+ val monitors = ErlangNode .newAtomicMap [Channel ,NonBlockingHashSet [Monitor ]](config)
206226 val pidCount = new AtomicInteger (0 )
207227 val pidSerial = new AtomicInteger (0 )
208228 val executor = poolFactory.createActorPool
0 commit comments