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