//[Test]
        public void SubscriptionArbiter()
        {
            {
                var sa = new SubscriptionArbiter();
                var bs = new BooleanSubscription();
                Benchmark.Run(() =>
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        sa.ArbiterSet(bs);
                    }
                    return(null);
                }, "Set");
            }

            {
                var sa = new SubscriptionArbiter();
                Benchmark.Run(() =>
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        sa.Request(1);
                    }
                    return(null);
                }, "Request");
            }

            {
                var sa = new SubscriptionArbiter();
                var bs = new BooleanSubscription();
                sa.ArbiterSet(bs);
                Benchmark.Run(() =>
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        sa.Request(1);
                    }
                    return(null);
                }, "Request-Upstream");
            }

            {
                var sa = new SubscriptionArbiter();
                sa.Request(long.MaxValue - 1);
                Benchmark.Run(() =>
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        sa.ArbiterProduced(1);
                    }
                    return(null);
                }, "Produced");
            }
        }
Beispiel #2
0
 public void OnSubscribe(ISubscription subscription)
 {
     arbiter.ArbiterSet(subscription);
 }