コード例 #1
0
ファイル: ActorSystem.cs プロジェクト: vgrichina/TinyActors
        public void AddMailbox(string path, Func<UntypedActor> createFunc, int maxCapacity)
        {
            // TODO: Allow to define default maxCapavity in declarative way

            Mailbox mailbox = new Mailbox(this, path, createFunc, maxCapacity);
            lock (this)
            {
                if (this.isStopping)
                {
                    throw new InvalidOperationException("Cannot add new mailbox to system which is being stopped");
                }
            }

            if (!this.mailboxes.TryAdd(path, mailbox))
            {
                throw new ArgumentException("There is already actor registered at path: " + path);
            }
            this.queue.Enqueue(mailbox);
        }
コード例 #2
0
        public void AddMailbox(string path, Func <UntypedActor> createFunc, int maxCapacity)
        {
            // TODO: Allow to define default maxCapavity in declarative way

            Mailbox mailbox = new Mailbox(this, path, createFunc, maxCapacity);

            lock (this)
            {
                if (this.isStopping)
                {
                    throw new InvalidOperationException("Cannot add new mailbox to system which is being stopped");
                }
            }

            if (!this.mailboxes.TryAdd(path, mailbox))
            {
                throw new ArgumentException("There is already actor registered at path: " + path);
            }
            this.queue.Enqueue(mailbox);
        }
コード例 #3
0
        private void RunThread()
        {
            int sleepInterval = 100; // TODO: Make this configurable?

            while (true)
            {
                Console.Write(".");
                Mailbox mailbox = null;
                if (this.queue.TryDequeue(out mailbox))
                {
                    if (mailbox.ProcessOutcomes())
                    {
                        mailbox.ProcessMessages();
                    }
                }

                Thread.Sleep(sleepInterval);

                if (mailbox != null)
                {
                    this.queue.Enqueue(mailbox);
                }
            }
        }
コード例 #4
0
 internal override bool Process(Mailbox mailbox)
 {
     return(this.task.IsCompleted);
 }
コード例 #5
0
 internal override bool Process(Mailbox mailbox)
 {
     return(mailbox.System.TrySendMessage(mailbox.Path, dstPath, message));
 }
コード例 #6
0
 internal abstract bool Process(Mailbox mailbox);