[Fact]
public void TestOnClientAndServerSetupWhenServerIsFaster()
{
var ints = new List<int>();
var completeInteger = NewEmptyCompletes<int>();
var expected = Enumerable.Range(0, 1000).ToList();
var server = new Thread(() => expected.ForEach(i => completeInteger.With(i)));
var client = new Thread(() => completeInteger.AndThen(i =>
{
ints.Add(i);
return i;
}).Repeat());
server.Start();
Thread.Sleep(10);
client.Start();
server.Join();
client.Join();
var intHashSet = new HashSet<int>(ints);
var expectedHashSet = new HashSet<int>(expected);
expectedHashSet.RemoveWhere(h => intHashSet.Contains(h));
Assert.Empty(expectedHashSet);
}
As you can see client is late by 10ms with processing. Attaching a continuation is too late because the server has already processed the continuation on its end.
On the JVM this is supported by the SinkAndSourceBasedCompletes but needs to be run agains the regular implementation of BasicCompletes in order to confirm that both has the same behavior.
This can be demonstrated with the following test
As you can see client is late by 10ms with processing. Attaching a continuation is too late because the server has already processed the continuation on its end.
On the JVM this is supported by the
SinkAndSourceBasedCompletes
but needs to be run agains the regular implementation ofBasicCompletes
in order to confirm that both has the same behavior.