Пример #1
0
        public void react(OtpActor actor)
        {
            OtpActorSchedTask task = new OtpActorSchedTask(actor);
            IEnumerator<OtpActor.Continuation> enumerator = task.Enumerator;

            if (!enumerator.MoveNext())
            {
                task.Active = false;
            }
            else
            {
                Monitor.Enter(runnable);
                try
                {
                    task.Active = true;
                    runnable.Enqueue(task);
                    if (runnable.Count == 1)
                    {
                        Monitor.Pulse(runnable);
                    }
                }
                finally
                {
                    Monitor.Exit(runnable);
                }
            }
        }
Пример #2
0
        public void react(OtpActor actor)
        {
            OtpActorSchedTask task = new OtpActorSchedTask(actor);
            IEnumerator <OtpActor.Continuation> enumerator = task.Enumerator;

            if (!enumerator.MoveNext())
            {
                task.Active = false;
            }
            else
            {
                Monitor.Enter(runnable);
                try
                {
                    task.Active = true;
                    runnable.Enqueue(task);
                    if (runnable.Count == 1)
                    {
                        Monitor.Pulse(runnable);
                    }
                }
                finally
                {
                    Monitor.Exit(runnable);
                }
            }
        }
Пример #3
0
 public void react(OtpActor actor)
 {
     sched.react(actor);
 }
 public void PostInitialise()
 {
     if (m_node != null)
     {
         m_mbox = (OtpActorMbox)m_node.createMbox("kernel", false);
         m_kernel = new KernelActor(m_scene, m_source, m_node, m_mbox);
         m_node.react(m_kernel);
     }
 }
Пример #5
0
 public OtpActorSchedTask(OtpActor actor)
 {
     actor.Task = this;
     this.actor = actor;
     this.enumerator = actor.GetEnumerator();
 }
Пример #6
0
 public void react(OtpActor actor)
 {
     sched.react(actor);
 }
Пример #7
0
 public OtpActorSchedTask(OtpActor actor)
 {
     actor.Task      = this;
     this.actor      = actor;
     this.enumerator = actor.GetEnumerator();
 }
Пример #8
0
        private void schedule()
        {
            Monitor.Enter(runnable);
            try
            {
                while (runnable.Count == 0)
                {
                    Monitor.Wait(runnable);
                }

                OtpActorSchedTask task  = runnable.Dequeue();
                OtpActor          actor = task.Actor;
                IEnumerator <OtpActor.Continuation> enumerator = task.Enumerator;

                Monitor.Enter(task);
                try
                {
                    if (task.Active)
                    {
                        OtpMsg msg = actor.Mbox.receiveMsg();

                        if (msg == null)
                        {
                            return;
                        }

                        ThreadPool.QueueUserWorkItem
                            (delegate(Object state)
                        {
                            Monitor.Enter(task);
                            try
                            {
                                OtpActor.Continuation cont = enumerator.Current;

                                cont(msg);

                                if (!enumerator.MoveNext())
                                {
                                    task.Active = false;
                                }
                            }
                            catch (Exception e)
                            {
                                log.Info("Exception was thrown from running actor: " + e.Message);
                            }
                            finally
                            {
                                Monitor.Exit(task);
                            }
                        });
                    }
                }
                finally
                {
                    Monitor.Exit(task);
                }
            }
            finally
            {
                Monitor.Exit(runnable);
            }
        }