示例#1
0
 public void UnlockMutex(IMailbox<object> me)
 {
     Safety.Assert(owner == me);
     owner = null;
     if (lockQueue.Count <= 0) return;
     owner = lockQueue[0];
     lockQueue.RemoveAt(0);
     owner.Send(new object());
 }
示例#2
0
 public void CheckMessages(IMailbox<string> res)
 {
     StringBuilder sb = new StringBuilder();
     foreach (var m in _messages)
     {
         sb.Append($"From: {m.Item1};\n Message: {m.Item2}\n\n");
     }
     res.Send(sb.ToString());
 }
示例#3
0
        public void LockMutex(IMailbox<object> me)
        {
            if (owner == null)
            {
                owner = me;
                me.Send(new object());
                return;
            }

            lockQueue.Add(me);
        }