Changeset 13945


Ignore:
Timestamp:
06/29/16 00:24:10 (3 years ago)
Author:
thasling
Message:

#2615:
fixed major bug in PeerNetworkMessageHandler, because one queue was missing for the sending queues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs

    r13937 r13945  
    2020
    2121    //provides current population for the higher layer IMigrationOperator
    22     //to queues are used to gather and and provide population more efficiently
     22    //two queues are used to gather and and provide population more efficiently
    2323    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
    2528    private SizedConcurrentQueue<byte[]> readQueue;
    2629
     
    3841        }; // TODO: get own peerinfo
    3942
    40         writeQueue = new SizedConcurrentQueue<byte[]>();
     43        writeQueueOriginal = new SizedConcurrentQueue<byte[]>();
     44        writeQueueAlternative = new SizedConcurrentQueue<byte[]>();
    4145        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;
    4449
    4550        host = new WcfMessageService();
     
    9297        byte[] item = null;
    9398        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;
    97104        }
    98105
    99106        //creating resultset
    100         while (!readQueue.IsEmpty) {
    101           if (readQueue.TryDequeue(out item)) {
     107        while (!writeQueueAlternative.IsEmpty) {
     108          if (writeQueueAlternative.TryDequeue(out item)) {
    102109            res.Add(item);
    103110          }
     
    137144        lock (activeQueueLocker) {
    138145          foreach (byte[] item in e.data) {
    139             writeQueue.Enqueue(item);
     146            writeQueueOriginal.Enqueue(item);
    140147          }
    141148        }
Note: See TracChangeset for help on using the changeset viewer.