/// <summary> /// 消费者 线程池轮询缓冲区 /// </summary> private void threadPool() { enqueue(); start(CallbackType.ThreadPool, TestType.MessageDistributionDequeue); using (AutoCSer.CacheServer.MessageQueue.Abstract.DistributionConsumer consumer1 = distributor.CreateConsumer(onMessage, getConfig())) using (AutoCSer.CacheServer.MessageQueue.Abstract.DistributionConsumer consumer2 = distributor.CreateConsumer(onMessage, getConfig())) { wait(); } client.RemoveDataStructure(cacheName); }
/// <summary> /// 消费者 线程池轮询缓冲区(生产消费实时并行测试) /// </summary> private void threadPoolMixing() { client.RemoveDataStructure(cacheName); distributor = client.GetOrCreateDataStructure <Distributor <Binary <Message> > >(cacheName); bitArray.SetAll(false); errorCount = messageIndex = 0; start(CallbackType.ThreadPool, TestType.MessageDistributionMixing, 2); using (AutoCSer.CacheServer.MessageQueue.Abstract.DistributionConsumer consumer1 = distributor.CreateConsumer(onMessageInterlocked, getConfig())) using (AutoCSer.CacheServer.MessageQueue.Abstract.DistributionConsumer consumer2 = distributor.CreateConsumer(onMessageInterlocked, getConfig())) { for (int index = 0; index != count; ++index) { distributor.EnqueueStream(new Message { Value = index }, enqueueCallbackInterlockedReturnParameter); } wait(); } client.RemoveDataStructure(cacheName); }