Пример #1
0
        private static void TrySend(int numThreads,
                                    int numCount,
                                    int ratioDoubleAdd,
                                    UpdateDispatchViewModel updateDispatchView,
                                    DispatchService dispatchService)
        {
            // execute
            IExecutorService threadPool = Executors.NewFixedThreadPool(numThreads);
            var future    = new Future <bool> [numThreads];
            var callables = new DispatchCallable[numThreads];
            var producer  = new DispatchProducer(updateDispatchView);

            for (int i = 0; i < numThreads; i++)
            {
                callables[i] = new DispatchCallable(producer, i, numCount, ratioDoubleAdd, updateDispatchView,
                                                    dispatchService);
                future[i] = threadPool.Submit(callables[i]);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(new TimeSpan(0, 0, 10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }
        }
Пример #2
0
 public DispatchCallable(DispatchProducer sharedProducer, int threadNum, int numActions, int ratioDoubleAdd,
                         UpdateDispatchViewModel updateDispatchView, DispatchService dispatchService)
 {
     _sharedProducer     = sharedProducer;
     _threadNum          = threadNum;
     _numActions         = numActions;
     _ratioDoubleAdd     = ratioDoubleAdd;
     _updateDispatchView = updateDispatchView;
     _dispatchService    = dispatchService;
 }
Пример #3
0
 public DispatchProducer(UpdateDispatchViewModel dispatchProcessor)
 {
     this.dispatchProcessor = dispatchProcessor;
 }
Пример #4
0
 public DispatchFuture(UpdateDispatchViewModel view, DispatchFuture earlier)
 {
     this.view    = view;
     this.earlier = earlier;
 }