Changeset 13946


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

#2615:
Fixed bug with reading queues
made all lock-objects static

Location:
branches/thasling/DistributedGA/DistributedGA.Core/Implementation
Files:
3 edited

Legend:

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

    r13945 r13946  
    2121    //provides current population for the higher layer IMigrationOperator
    2222    //two queues are used to gather and and provide population more efficiently
    23     private object activeQueueLocker = new object();
    24     private SizedConcurrentQueue<byte[]> writeQueueOriginal;
    25     private SizedConcurrentQueue<byte[]> writeQueueAlternative;
    26 
    27     //queue for recieved items
     23    private static object activeQueueLocker = new Object();
     24    private SizedConcurrentQueue<byte[]> writeQueue;
    2825    private SizedConcurrentQueue<byte[]> readQueue;
    2926
    3027    //uses IMessageService for recieving population from one peer at once
    3128    private IMessageService host = null;
    32 
    3329
    3430
     
    4137        }; // TODO: get own peerinfo
    4238
    43         writeQueueOriginal = new SizedConcurrentQueue<byte[]>();
    44         writeQueueAlternative = new SizedConcurrentQueue<byte[]>();
     39        writeQueue = new SizedConcurrentQueue<byte[]>();
    4540        readQueue = new SizedConcurrentQueue<byte[]>();
    46         writeQueueOriginal.Limit = 1000;
    47         writeQueueAlternative.Limit = 1000;
    48         readQueue.Limit = writeQueueOriginal.Limit;
     41        writeQueue.Limit = 1000;
     42        readQueue.Limit = writeQueue.Limit;
    4943
    5044        host = new WcfMessageService();
     
    9993          //changing the current queue for storing items to send
    10094          //then read from the now unselect queue
    101           var tmp = writeQueueAlternative;
    102           writeQueueAlternative = writeQueueOriginal;
    103           writeQueueOriginal = tmp;
     95          var tmp = readQueue;
     96          readQueue = writeQueue;
     97          writeQueue = tmp;
    10498        }
    10599
    106100        //creating resultset
    107         while (!writeQueueAlternative.IsEmpty) {
    108           if (writeQueueAlternative.TryDequeue(out item)) {
     101        while (!readQueue.IsEmpty) {
     102          if (readQueue.TryDequeue(out item)) {
    109103            res.Add(item);
    110104          }
     
    144138        lock (activeQueueLocker) {
    145139          foreach (byte[] item in e.data) {
    146             writeQueueOriginal.Enqueue(item);
     140            writeQueue.Enqueue(item);
    147141          }
    148142        }
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs

    r13943 r13946  
    1818    private Timer timer; //sends cached messages to network in background
    1919
    20     private Object timerLock = new Object();
     20    private static Object timerLock = new Object();
    2121
    2222    public void Init(PeerInfo source) {
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs

    r13943 r13946  
    1616    private Timer timer = null; //sends heartbeat to contact-server
    1717
    18     private Object timerLock = new Object();
     18    private static Object timerLock = new Object();
    1919
    2020    private ChannelFactory<IContactService> myChannelFactory;
Note: See TracChangeset for help on using the changeset viewer.