Exemplo n.º 1
0
        // own actor.
        // update the actor
        // and watch operations on the actor
        private void ActorEnter(Region region, long id, Dictionary <int, ByteString> properties)
        {
            /* this lock is not necessary */            //lock( _region_actor )
            {
                // find actor
                // if actor is found, update its properties and replace the dest region.
                // because before sending the message, the same actor may change region several times,
                // the latest dest region will be the true that the actor truely enters.
                ActorUtils.RegionActorPair rap = null;
                if (_region_actor.TryGetValue(id, out rap))
                {
                    // copy properties
                    ActorUtils.CopyProperties(properties, rap.actor.Ptypes, rap.actor.Pdatas);

                    // set new dest
                    // replace the region was set
                    rap.dest = region;
                }
                // else insert the actor.
                else
                {
                    rap       = new ActorUtils.RegionActorPair();
                    rap.actor = ActorUtils.CreateActor(id, properties);
                    rap.dest  = region;

                    _region_actor.Add(id, rap);
                }
            }
        }
Exemplo n.º 2
0
        // actor exit
        private void ActorExit(Region region, long id)
        {
            /* this lock is not necessary */            //lock( _region_actor )
            {
                // find actor
                // if the actor is found, only set null src region.
                // because before sending the message, the same actor may change region several times,
                // the first src regin should be the truely region that the actor exits from.
                ActorUtils.RegionActorPair rap = null;
                if (_region_actor.TryGetValue(id, out rap))
                {
                    // set old region
                    if (null == rap.src)
                    {
                        rap.src = region;
                    }
                }
                else
                {
                    rap       = new ActorUtils.RegionActorPair();
                    rap.actor = ActorUtils.CreateActor(id, null);
                    rap.src   = region;

                    _region_actor.Add(id, rap);
                }
            }
        }
Exemplo n.º 3
0
 // update properties
 public void ActorUpdate(Region region, long id, Dictionary <int, ByteString> properties)
 {
     /* this lock is not necessary */            //lock( _message )
     {
         Actor a = ActorUtils.FindActor(id, _message.UpdateActors);
         if (null == a)
         {
             a = ActorUtils.CreateActor(id, properties);
             _message.UpdateActors.Add(a);
         }
         else
         {
             ActorUtils.CopyProperties(properties, a.Ptypes, a.Pdatas);
         }
     }
 }