Improve callstack for LoggingThreadPool
This commit is contained in:
parent
663b825d97
commit
adc3e63ecc
|
|
@ -12,15 +12,26 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
||||||
{
|
{
|
||||||
private readonly IKestrelTrace _log;
|
private readonly IKestrelTrace _log;
|
||||||
|
|
||||||
private readonly WaitCallback _runAction;
|
private WaitCallback _runAction;
|
||||||
private readonly WaitCallback _cancelTcs;
|
private WaitCallback _cancelTcs;
|
||||||
private readonly WaitCallback _completeTcs;
|
private WaitCallback _completeTcs;
|
||||||
|
|
||||||
public LoggingThreadPool(IKestrelTrace log)
|
public LoggingThreadPool(IKestrelTrace log)
|
||||||
{
|
{
|
||||||
_log = log;
|
_log = log;
|
||||||
|
|
||||||
// Curry and capture log in closures once
|
// Curry and capture log in closures once
|
||||||
|
// The currying is done in functions of the same name to improve the
|
||||||
|
// call stack for exceptions and profiling else it shows up as LoggingThreadPool.ctor>b__4_0
|
||||||
|
// and you aren't sure which of the 3 functions was called.
|
||||||
|
RunAction();
|
||||||
|
CompleteTcs();
|
||||||
|
CancelTcs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunAction()
|
||||||
|
{
|
||||||
|
// Capture _log in a singleton closure
|
||||||
_runAction = (o) =>
|
_runAction = (o) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -32,7 +43,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
||||||
_log.LogError(0, e, "LoggingThreadPool.Run");
|
_log.LogError(0, e, "LoggingThreadPool.Run");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CompleteTcs()
|
||||||
|
{
|
||||||
|
// Capture _log in a singleton closure
|
||||||
_completeTcs = (o) =>
|
_completeTcs = (o) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -44,7 +59,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
||||||
_log.LogError(0, e, "LoggingThreadPool.Complete");
|
_log.LogError(0, e, "LoggingThreadPool.Complete");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelTcs()
|
||||||
|
{
|
||||||
|
// Capture _log in a singleton closure
|
||||||
_cancelTcs = (o) =>
|
_cancelTcs = (o) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue