Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/12/11 15:50:06 (13 years ago)
Author:
epitzer
Message:

Replace the ExternalEvaluator's Client property with a CheckedItemCollection of clients and synchronize access so every client is used by only one thread at a time. (#1526)

File:
1 edited

Legend:

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

    r6183 r6189  
    5353
    5454    #region Parameters
    55     public IValueParameter<IEvaluationServiceClient> ClientParameter {
    56       get { return (IValueParameter<IEvaluationServiceClient>)Parameters["Client"]; }
     55    public IValueParameter<CheckedItemCollection<IEvaluationServiceClient>> ClientsParameter {
     56      get { return (IValueParameter<CheckedItemCollection<IEvaluationServiceClient>>)Parameters["Clients"]; }
    5757    }
    5858    public IValueParameter<IExternalEvaluationProblemEvaluator> EvaluatorParameter {
     
    144144      UserDefinedSolutionCreator solutionCreator = new UserDefinedSolutionCreator();
    145145
    146       Parameters.Add(new ValueParameter<IEvaluationServiceClient>("Client", "The client that is used to communicate with the external application.", new EvaluationServiceClient()));
     146      Parameters.Add(new ValueParameter<CheckedItemCollection<IEvaluationServiceClient>>("Clients", "The clients that are used to communicate with the external application.", new CheckedItemCollection<IEvaluationServiceClient>() { new EvaluationServiceClient() }));
    147147      Parameters.Add(new ValueParameter<IExternalEvaluationProblemEvaluator>("Evaluator", "The evaluator that collects the values to exchange.", evaluator));
    148148      Parameters.Add(new ValueParameter<ISolutionCreator>("SolutionCreator", "An operator to create the solution components.", solutionCreator));
     
    155155      InitializeOperators();
    156156      AttachEventHandlers();
     157    }
     158    [StorableHook(HookType.AfterDeserialization)]
     159    private void AfterDeserialization() {
     160      // BackwardsCompatibility3.3
     161      #region Backwards compatible code, remove with 3.4
     162      if (!Parameters.ContainsKey("Clients")) {
     163        Parameters.Add(new ValueParameter<CheckedItemCollection<IEvaluationServiceClient>>("Clients", "The clients that are used to communicate with the external application.", new CheckedItemCollection<IEvaluationServiceClient>() { new EvaluationServiceClient() }));
     164        if (Parameters.ContainsKey("Client")) {
     165          var client = ((IValueParameter<IEvaluationServiceClient>)Parameters["Client"]).Value;
     166          if (client != null)
     167            ClientsParameter.Value = new CheckedItemCollection<IEvaluationServiceClient>() { client };
     168          Parameters.Remove("Client");
     169        }
     170      }
     171      #endregion
    157172    }
    158173
     
    227242    }
    228243    private void ParameterizeEvaluator() {
    229       Evaluator.ClientParameter.ActualName = ClientParameter.Name;
     244      Evaluator.ClientsParameter.ActualName = ClientsParameter.Name;
    230245    }
    231246    private void ParameterizeOperators() {
Note: See TracChangeset for help on using the changeset viewer.