void HandOut(SimPacket msg) { _ackNumber = msg.NextSeqNumber; if (_pendingRead != null) { _pendingRead.SetResult(msg); _pendingRead = null; } else { _readBuffer.Enqueue(msg); } }
void AddEstablishedConnection(SimConn conn) { var ready = new ClientConn(conn); if (_poll != null) { _poll.SetResult(ready); _poll = null; } else { _incoming.Enqueue(ready); } }
public void SettingResultSyncCompletesPromise() { var test = new TestDef() { MaxSteps = 100, }; var completed = TimeSpan.MinValue; bool result = false; test.RunScript(async env => { var promise = new SimFuture <bool>(5000); promise.SetResult(true); result = await promise.Task; completed = env.Time; }); Assert.IsTrue(result); Assert.AreEqual(TimeSpan.Zero, completed); }