Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
                }
            }
        }
Exemple #4
0
 internal override bool Process(Mailbox mailbox)
 {
     return(this.task.IsCompleted);
 }
Exemple #5
0
 internal override bool Process(Mailbox mailbox)
 {
     return(mailbox.System.TrySendMessage(mailbox.Path, dstPath, message));
 }
Exemple #6
0
 internal abstract bool Process(Mailbox mailbox);