protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources if (latch != null) { latch.Dispose(); latch = null; } } }
// AVRO-625 [Test] // Currently, SocketTransceiver does not permit out-of-order requests on a stateful connection. public void Test() { var waitLatch = new CountdownLatch(1); var simpleResponder = new SimpleResponder(waitLatch); server = new SocketServer("localhost", 0, simpleResponder); server.Start(); int port = server.Port; transceiver = new SocketTransceiver("localhost", port); proxy = new GenericRequestor(transceiver, SimpleResponder.Protocol); // Step 1: proxy.GetRemote(); // force handshake new Thread(x => { // Step 2a: waitLatch.Wait(); var ack = new GenericRecord(SimpleResponder.Protocol.Messages["ack"].Request); // Step 2b: proxy.Request("ack", ack); }).Start(); /* * 3. Execute the Client.hello("wait") RPC, which will block until the * Client.ack() call has completed in the background thread. */ var request = new GenericRecord(SimpleResponder.Protocol.Messages["hello"].Request); request.Add("greeting", "wait"); var response = (string)proxy.Request("hello", request); // 4. If control reaches here, both RPCs have executed concurrently Assert.AreEqual("wait", response); }
public void Reset() { allMessages = new CountdownLatch(5); }
public SimpleResponder(CountdownLatch waitLatch) : base(Protocol) { this.waitLatch = waitLatch; }