public void TestInsertExtract() { var chan = New.Channel <int>(); chan.Insert(1); chan.Insert(2); chan.Insert(3); var f0 = chan.Extract(); var f1 = chan.Extract(); var f2 = chan.Extract(); var f3 = chan.Extract(); Root.Add(chan); Step(5); Assert.IsTrue(f0.Available); Assert.IsTrue(f1.Available); Assert.IsTrue(f2.Available); Assert.IsFalse(f3.Available); Assert.AreEqual(1, f0.Value); Assert.AreEqual(2, f1.Value); Assert.AreEqual(3, f2.Value); }
public IChannel <ICardAgent> DrawCards(uint n) { var channel = New.Channel <ICardAgent>(); _Node.Add(New.Coroutine(DrawCardsCoro, n, channel)); return(channel); }
public void TestExtractInsert() { var chan = New.Channel <int>(); var f0 = chan.Extract(); var f1 = chan.Extract(); var f2 = chan.Extract(); chan.Insert(1); chan.Insert(2); chan.Insert(3); Root.Add(chan); Step(5); Assert.AreEqual(1, f0.Value); Assert.AreEqual(2, f1.Value); Assert.AreEqual(3, f2.Value); }