示例#1
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);
        }
示例#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);