Skip to content

Commit

Permalink
Fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcitectus committed Apr 10, 2016
1 parent 91cc0ea commit 1307698
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
Binary file modified lib/Bib3.dll
Binary file not shown.
63 changes: 25 additions & 38 deletions src/Sanderling/Sanderling.Exe/App.Interface.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bib3;
using Bib3.Synchronization;
using BotEngine.Interface;
using Sanderling.Interface;
using System;
Expand Down Expand Up @@ -48,21 +49,18 @@ partial class App

int MotionInvalidateMeasurementDelay = 400;

Int64? FromMotionExecutionMemoryMeasurementTimeMin
{
get
Int64? FromMotionExecutionMemoryMeasurementTimeMin =>
MotorLock.BranchOnTryEnter(() =>
{
lock (MotorLock)
{
var motionLastTime = MotionLastTime;
var motionLastTime = MotionLastTime;
if (!motionLastTime.HasValue)
return null;
if (!motionLastTime.HasValue)
return null;
return motionLastTime.Value + MotionInvalidateMeasurementDelay;
}
}
}
return motionLastTime.Value + MotionInvalidateMeasurementDelay;
},
() => (Int64?)Int64.MaxValue);

Int64? MeasurementRecentEnoughTime => new[]
{
Expand All @@ -88,44 +86,33 @@ FromProcessMeasurement<MemoryMeasurementEvaluation> MemoryMeasurementIfRecentEno
{
get
{
lock (MotorLock)
{
var MemoryMeasurementLast = this.MemoryMeasurementLast;
var MeasurementRecentEnoughTime = this.MeasurementRecentEnoughTime;
var MemoryMeasurementLast = this.MemoryMeasurementLast;
var MeasurementRecentEnoughTime = this.MeasurementRecentEnoughTime;

if (MemoryMeasurementLast?.Begin < MeasurementRecentEnoughTime)
return null;
if (MemoryMeasurementLast?.Begin < MeasurementRecentEnoughTime)
return null;

return MemoryMeasurementLast;
}
return MemoryMeasurementLast;
}
}

FromProcessMeasurement<MemoryMeasurementEvaluation> FromScriptRequestMemoryMeasurementEvaluation()
{
lock (MotorLock)
{
var BeginTime = GetTimeStopwatch();
var BeginTime = GetTimeStopwatch();

while (true)
{
var MemoryMeasurementIfRecentEnough = this.MemoryMeasurementIfRecentEnough;
while (true)
{
var MemoryMeasurementIfRecentEnough = this.MemoryMeasurementIfRecentEnough;

if (null != MemoryMeasurementIfRecentEnough)
{
return MemoryMeasurementIfRecentEnough;
}
if (null != MemoryMeasurementIfRecentEnough)
return MemoryMeasurementIfRecentEnough;

var RequestAge = GetTimeStopwatch() - BeginTime;
var RequestAge = GetTimeStopwatch() - BeginTime;

if (Sanderling.Script.Impl.HostToScript.FromScriptRequestMemoryMeasurementDelayMax < RequestAge)
{
// Timeout
return null;
}
if (Sanderling.Script.Impl.HostToScript.FromScriptRequestMemoryMeasurementDelayMax < RequestAge)
return null; // Timeout

Thread.Sleep(44);
}
Thread.Sleep(44);
}
}

Expand Down

0 comments on commit 1307698

Please sign in to comment.