Пример #1
0
        private ActorUseScope GetExistingActor(ActorId actorId, bool timerUse)
        {
            ActorUseScope scope = null;
            ActorBase     activeActor;

            if (this.activeActors.TryGetValue(actorId, out activeActor))
            {
                scope = ActorUseScope.TryCreate(activeActor, timerUse);
            }

            if (scope == null)
            {
                throw new ObjectDisposedException("actor");
            }

            return(scope);
        }
Пример #2
0
        private ActorUseScope GetOrCreateActor(ActorId actorId, bool timerUse, bool createDummyActor)
        {
            ActorUseScope scope = null;
            var           sw    = new SpinWait();

            while (scope == null)
            {
                ActorBase actor;
                if (!this.activeActors.TryGetValue(actorId, out actor))
                {
                    actor = this.activeActors.GetOrAdd(actorId, l => this.CreateActor(actorId, createDummyActor));
                }

                scope = ActorUseScope.TryCreate(actor, timerUse);
                if (scope == null)
                {
                    sw.SpinOnce();
                }
            }

            return(scope);
        }