Throtting constraints
I think my understanding of throtting constraints is broken. I assumed the following code would
only print "3" and "c", but it prints all values posted to both ports.
using
(Dispatcher dispatcher =newDispatcher()){
DispatcherQueue dq =newDispatcherQueue( "Test",dispatcher,
TaskExecutionPolicy.ConstrainQueueDepthDiscardTasks,1);
Port<int> intPort =newPort<int>(); Port<string> stringPort =newPort<string>(); Port<Shutdown> endPort =newPort<Shutdown>();intPort.Post(1);
intPort.Post(2);
intPort.Post(3);
stringPort.Post("a");
stringPort.Post(
"b");stringPort.Post(
"c");Arbiter.Activate(dq,Arbiter.Interleave(
newTeardownReceiverGroup(
Arbiter.Receive(false, endPort,delegate(Shutdown s)
{
})),
newExclusiveReceiverGroup(
Arbiter.Receive(true, intPort,delegate(int i)
{
Thread.Sleep(1000);
Console.WriteLine(i.ToString());
}),
Arbiter.Receive(true, stringPort,delegate(string s)
{
Thread.Sleep(1000);
Console.WriteLine(s);
})),
newConcurrentReceiverGroup()));
Console.ReadLine();endPort.Post(
newShutdown());}
Would someone tell me why this behaves the way it does?
The Thread.Sleep() call is there to simulate a consumer much slower than its producer...

