Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/21/11 11:11:38 (13 years ago)
Author:
epitzer
Message:

Correct locking construct for external evaluation on multiple clients and simplify string formatting (#1526)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/ExternalEvaluator.cs

    r6189 r6460  
    5959    #region Fields
    6060    protected HashSet<IEvaluationServiceClient> activeClients = new HashSet<IEvaluationServiceClient>();
    61     protected object clientLock = new object();
    62     protected AutoResetEvent clientAvailable = new AutoResetEvent(false);
     61    protected object clientLock = new object();   
    6362    #endregion
    6463
     
    109108        client = Clients.CheckedItems.FirstOrDefault(c => !activeClients.Contains(c));
    110109        while (client == null && Clients.Count > 0) {
    111           Monitor.Exit(clientLock);
    112           clientAvailable.WaitOne();
    113           Monitor.Enter(clientLock);
     110          Monitor.Wait(clientLock);
    114111          client = Clients.CheckedItems.FirstOrDefault(c => !activeClients.Contains(c));
    115112        }
     
    122119        lock (clientLock) {
    123120          activeClients.Remove(client);
    124           clientAvailable.Set();
     121          Monitor.PulseAll(clientLock);
    125122        }
    126123      }
Note: See TracChangeset for help on using the changeset viewer.