Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13937


Ignore:
Timestamp:
06/24/16 21:23:47 (8 years ago)
Author:
thasling
Message:

#2615:
implemented ConcurrentQueue
made minor changes in Dispose-methods

Location:
branches/thasling/DistributedGA
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/thasling/DistributedGA/DistributedGA.Core/DistributedGA.Core.csproj

    r13887 r13937  
    6464    <Compile Include="Interface\IPeerListManager.cs" />
    6565    <Compile Include="Properties\AssemblyInfo.cs" />
     66    <Compile Include="Util\SizedConcurrentQueue.cs" />
    6667  </ItemGroup>
    6768  <ItemGroup>
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs

    r13924 r13937  
    66using DistributedGA.Core.Domain;
    77using DistributedGA.Core.Interface;
     8using DistributedGA.Core.Util;
    89
    910namespace DistributedGA.Core.Implementation {
     
    2122    //to queues are used to gather and and provide population more efficiently
    2223    private object activeQueueLocker = new object();
    23     private ConcurrentQueue<byte[]> writeQueue;
    24     private ConcurrentQueue<byte[]> readQueue;
     24    private SizedConcurrentQueue<byte[]> writeQueue;
     25    private SizedConcurrentQueue<byte[]> readQueue;
    2526
    2627    //uses IMessageService for recieving population from one peer at once
     
    3738        }; // TODO: get own peerinfo
    3839
    39         writeQueue = new ConcurrentQueue<byte[]>();
    40         readQueue = new ConcurrentQueue<byte[]>();
    41 
     40        writeQueue = new SizedConcurrentQueue<byte[]>();
     41        readQueue = new SizedConcurrentQueue<byte[]>();
     42        writeQueue.Limit = 1000;
     43        readQueue.Limit = writeQueue.Limit;
    4244
    4345        host = new WcfMessageService();
    4446        ownInstance.Port = host.Init(ownInstance.IpAddress); //getting port, on which service is hostet
    45         host.OnDataRecieved += new EventHandler<MessageRecieveEventArgs>(OnPopulationRecieved);
     47        host.OnDataRecieved += new EventHandler<MessageRecieveEventArgs>(OnDataRecieved);
    4648
    4749        peerListManager = new WcfPeerListManager();
     
    131133    }
    132134
    133     private void OnPopulationRecieved(object sender, MessageRecieveEventArgs e) {
     135    private void OnDataRecieved(object sender, MessageRecieveEventArgs e) {
    134136      if (e != null) {
    135137        lock (activeQueueLocker) {
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs

    r13923 r13937  
    77using DistributedGA.Core.Domain;
    88using DistributedGA.Core.Interface;
     9using DistributedGA.Core.Util;
    910
    1011namespace DistributedGA.Core.Implementation {
     
    1314    private PeerInfo myself;
    1415
    15     private ConcurrentQueue<KeyValuePair<PeerInfo, byte[][]>> bufferedMessages;
     16    private SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[][]>> bufferedMessages;
    1617
    1718    private Timer timer; //sends cached messages to network in background
     
    1920    public void Init(PeerInfo source) {
    2021      myself = source;
    21       bufferedMessages = new ConcurrentQueue<KeyValuePair<PeerInfo, byte[][]>>();
     22      bufferedMessages = new SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[][]>>();
     23      bufferedMessages.Limit = 1000;
    2224      timer = new Timer(1000 * 60); //each 5 minutes
    2325      timer.Elapsed += GenerateSendingTasks;
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs

    r13923 r13937  
    6060      ((IClientChannel)heartbeatClient).Close();
    6161      myChannelFactory.Close();
     62      client = null;
     63      myChannelFactory = null;
    6264    }
    6365
Note: See TracChangeset for help on using the changeset viewer.