Changeset 13945
- Timestamp:
- 06/29/16 00:24:10 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs
r13937 r13945 20 20 21 21 //provides current population for the higher layer IMigrationOperator 22 //t o queues are used to gather and and provide population more efficiently22 //two queues are used to gather and and provide population more efficiently 23 23 private object activeQueueLocker = new object(); 24 private SizedConcurrentQueue<byte[]> writeQueue; 24 private SizedConcurrentQueue<byte[]> writeQueueOriginal; 25 private SizedConcurrentQueue<byte[]> writeQueueAlternative; 26 27 //queue for recieved items 25 28 private SizedConcurrentQueue<byte[]> readQueue; 26 29 … … 38 41 }; // TODO: get own peerinfo 39 42 40 writeQueue = new SizedConcurrentQueue<byte[]>(); 43 writeQueueOriginal = new SizedConcurrentQueue<byte[]>(); 44 writeQueueAlternative = new SizedConcurrentQueue<byte[]>(); 41 45 readQueue = new SizedConcurrentQueue<byte[]>(); 42 writeQueue.Limit = 1000; 43 readQueue.Limit = writeQueue.Limit; 46 writeQueueOriginal.Limit = 1000; 47 writeQueueAlternative.Limit = 1000; 48 readQueue.Limit = writeQueueOriginal.Limit; 44 49 45 50 host = new WcfMessageService(); … … 92 97 byte[] item = null; 93 98 lock (activeQueueLocker) { 94 var tmp = readQueue; 95 readQueue = writeQueue; 96 writeQueue = tmp; 99 //changing the current queue for storing items to send 100 //then read from the now unselect queue 101 var tmp = writeQueueAlternative; 102 writeQueueAlternative = writeQueueOriginal; 103 writeQueueOriginal = tmp; 97 104 } 98 105 99 106 //creating resultset 100 while (! readQueue.IsEmpty) {101 if ( readQueue.TryDequeue(out item)) {107 while (!writeQueueAlternative.IsEmpty) { 108 if (writeQueueAlternative.TryDequeue(out item)) { 102 109 res.Add(item); 103 110 } … … 137 144 lock (activeQueueLocker) { 138 145 foreach (byte[] item in e.data) { 139 writeQueue .Enqueue(item);146 writeQueueOriginal.Enqueue(item); 140 147 } 141 148 }
Note: See TracChangeset
for help on using the changeset viewer.