Skip to content

Commit

Permalink
Remove idle check from WP requests (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Nov 30, 2021
1 parent b0509e7 commit 95b80db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ public class Controller : IControllerLocal
private readonly int nextEndpointId;
private readonly object incrementLock = new object();

/// <summary>
/// Threshold for considering the communication channel idle.
/// </summary>
/// <remarks>
/// The default idle time is 100ms.
/// </remarks>
public TimeSpan IdleThreshold { get; set; } = TimeSpan.FromMilliseconds(100);

public IControllerHostLocal App { get; internal set; }

public CLRCapabilities Capabilities { get; set; }
Expand Down Expand Up @@ -59,7 +67,7 @@ internal set

public bool IsIdle()
{
return (DateTime.UtcNow - _lastActivity).TotalMilliseconds > 50;
return (DateTime.UtcNow - _lastActivity).TotalMilliseconds > IdleThreshold.TotalMilliseconds;
}

public bool Send(MessageRaw raw)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,6 @@ public WireProtocolRequest(OutgoingMessage outgoingMessage, int millisecondsTime

internal bool PerformRequest(IController controller)
{
const int sleepTimeMs = 10;
int attemptsCount = 10000 / sleepTimeMs;

// wait for controller to be idle
while (
!controller.IsIdle() &&
attemptsCount > 0)
{
Thread.Sleep(10);

attemptsCount--;
}

if(attemptsCount == 0)
{
// timeout waiting for idle controller
return false;
}

Debug.WriteLine($"Performing request");

DebuggerEventSource.Log.WireProtocolTxHeader(OutgoingMessage.Base.Header.CrcHeader
Expand Down Expand Up @@ -93,7 +74,6 @@ internal void RequestAborted()
OutgoingMessage.Base.Header.Seq,
OutgoingMessage.Base.Header.SeqReply,
RequestTimestamp);

}
}
}

0 comments on commit 95b80db

Please sign in to comment.