/// <summary> /// 添加数据到 /// </summary> private void enqueue() { client.RemoveDataStructure(cacheName); distributor = client.GetOrCreateDataStructure <Distributor <Binary <Message> > >(cacheName); start(CallbackType.Asynchronous, TestType.MessageDistributionEnqueue); for (int index = 0; index != count; ++index) { distributor.EnqueueStream(new Message { Value = index }, enqueueCallbackReturnParameter); } wait(); bitArray.SetAll(false); }
/// <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); }