public QualityMessage GetMessage(ExtensionRegistry extensions) { lock (lockObject) { if (message == null && rawMessage != null) message = QualityMessage.ParseFrom(ByteString.CopyFrom(rawMessage), extensions); } return message; }
public void SetMessage(QualityMessage value) { lock (lockObject) { message = value; rawMessage = value.ToByteArray(); } }
public QualityMessage Evaluate(SolutionMessage solution, ExtensionRegistry qualityExtensions) { int tries = 0, maxTries = RetryParameter.Value.Value; bool success = false; QualityMessage result = null; while (!success) { try { tries++; CheckAndOpenChannel(); Channel.Send(solution); result = (QualityMessage)Channel.Receive(QualityMessage.CreateBuilder(), qualityExtensions); success = true; } catch (InvalidOperationException) { throw; } catch { if (tries >= maxTries) { throw; } } } if (result != null && result.SolutionId != solution.SolutionId) { throw new InvalidDataException(Name + ": Received a quality for a different solution."); } return(result); }
private QualityMessage CreateBasicQualityMessage() { var extensions = ExtensionRegistry.CreateInstance(); ExternalEvaluationMessages.RegisterAllExtensions(extensions); return(QualityMessage.ParseFrom(ByteString.CopyFrom(rawMessage), extensions)); }
public override IMessage Receive(IBuilder builder, ExtensionRegistry extensions) { QualityMessage message; lock (input) { // only one thread can read from the stream at one time message = QualityMessage.ParseDelimitedFrom(input, extensions); } return(message); }
public QualityMessage GetMessage(ExtensionRegistry extensions) { lock (lockObject) { if (message == null && rawMessage != null) { message = QualityMessage.ParseFrom(ByteString.CopyFrom(rawMessage), extensions); } } return(message); }
private void ReceiveAsync(object callbackInfo) { var info = (ReceiveAsyncInfo)callbackInfo; QualityMessage message = null; try { message = (QualityMessage)Channel.Receive(QualityMessage.CreateBuilder(), info.QualityExtensions); } catch { } if (message != null && message.SolutionId != info.SolutionMessage.SolutionId) { throw new InvalidDataException(Name + ": Received a quality for a different solution."); } info.CallbackDelegate.Invoke(message); }
public override IOperation Apply() { QualityMessage answer = EvaluateOnNextAvailableClient(BuildSolutionMessage()); if (QualityParameter.ActualValue == null) { QualityParameter.ActualValue = new DoubleValue(answer.Quality); } else { QualityParameter.ActualValue.Value = answer.Quality; } return(base.Apply()); }