Exemplo n.º 1
0
        public static void ReadyToExecute(IActor actor)
        {
            if (actor.Exited)
            {
                return;
            }

            var actorStatus = Interlocked.CompareExchange(
                ref actor.Context.Status,
                ActorContext.EXECUTING,
                ActorContext.AVAILABLE);

            if (actorStatus == ActorContext.AVAILABLE)
            {
                Task.Factory.StartNew(() => GateKeeper.Execute(actor));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// For the client to give a work item to the actor.
        /// </summary>
        /// <param name="item"></param>
        public void AddWorkItem(T item)
        {
            _queue.Enqueue(item);

            GateKeeper.ReadyToExecute(this);
        }