public void Scenario1_DeadlocksWithoutEager() { ExecuteMpiProgram(2, mpi => { mpi.MpiInit(); int rank = mpi.GetRank(); if (rank == 0) { // P0 SendHandle h00 = mpi.SendAsync(1, "s00", false); mpi.Wait(h00); // DEADLOCKS on wait because the barrier's can't be satisfied mpi.Barrier(); } else { // P1 mpi.Barrier(); // Never gets past here because P0 is waiting for us to recv first. ReceiveHandle h11 = mpi.ReceiveAsync(0); string msg1 = mpi.Wait(h11); Assert.AreEqual("s00", msg1); } mpi.MpiFinalize(); }); }
public void Scenario1_DoesNotDeadlockWhenEager() { ExecuteMpiProgram(2, mpi => { mpi.MpiInit(); int rank = mpi.GetRank(); if (rank == 0) { // P0 SendHandle h00 = mpi.SendAsync(1, "s00", true); // Does Not DEADLOCK on wait because it will return when the string is copied // to a local buffer. mpi.Wait(h00); mpi.Barrier(); } else { // P1 mpi.Barrier(); // Never gets past here because P0 is waiting for us to recv first. ReceiveHandle h11 = mpi.ReceiveAsync(0); string msg1 = mpi.Wait(h11); Assert.AreEqual("s00", msg1); } mpi.MpiFinalize(); }); }
private void AcceptCompleted(IAsyncResult ar) { HttpListener listener = (HttpListener)ar.AsyncState; HttpListenerContext context = listener.EndGetContext(ar); ReceiveHandle.BeginInvoke(context, null, null); //等待接收下一次请求 StartAccept(); }