-Async cleanup
This commit is contained in:
@@ -1138,7 +1138,7 @@ namespace Newtonsoft.Json
|
|||||||
switch (_currentState)
|
switch (_currentState)
|
||||||
{
|
{
|
||||||
case State.PostValue:
|
case State.PostValue:
|
||||||
if (await ParsePostValueAsync(true, cancellationToken))
|
if (await ParsePostValueAsync(true, cancellationToken).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1273,7 +1273,7 @@ namespace Newtonsoft.Json
|
|||||||
switch (_currentState)
|
switch (_currentState)
|
||||||
{
|
{
|
||||||
case State.PostValue:
|
case State.PostValue:
|
||||||
if (await ParsePostValueAsync(true, cancellationToken))
|
if (await ParsePostValueAsync(true, cancellationToken).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1399,7 +1399,7 @@ namespace Newtonsoft.Json
|
|||||||
switch (_currentState)
|
switch (_currentState)
|
||||||
{
|
{
|
||||||
case State.PostValue:
|
case State.PostValue:
|
||||||
if (await ParsePostValueAsync(true, cancellationToken))
|
if (await ParsePostValueAsync(true, cancellationToken).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1535,7 +1535,7 @@ namespace Newtonsoft.Json
|
|||||||
switch (_currentState)
|
switch (_currentState)
|
||||||
{
|
{
|
||||||
case State.PostValue:
|
case State.PostValue:
|
||||||
if (await ParsePostValueAsync(true, cancellationToken))
|
if (await ParsePostValueAsync(true, cancellationToken).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ namespace Newtonsoft.Json
|
|||||||
// Local functions, params renamed (capitalized) so as not to capture and allocate when calling async
|
// Local functions, params renamed (capitalized) so as not to capture and allocate when calling async
|
||||||
async Task AwaitProperty(Task task, int LevelsToComplete, JsonToken token, JsonContainerType Type, CancellationToken CancellationToken)
|
async Task AwaitProperty(Task task, int LevelsToComplete, JsonToken token, JsonContainerType Type, CancellationToken CancellationToken)
|
||||||
{
|
{
|
||||||
await task;
|
await task.ConfigureAwait(false);
|
||||||
|
|
||||||
// Finish current loop
|
// Finish current loop
|
||||||
if (_formatting == Formatting.Indented)
|
if (_formatting == Formatting.Indented)
|
||||||
@@ -343,7 +343,7 @@ namespace Newtonsoft.Json
|
|||||||
|
|
||||||
async Task AwaitIndent(Task task, int LevelsToComplete, JsonToken token, JsonContainerType Type, CancellationToken CancellationToken)
|
async Task AwaitIndent(Task task, int LevelsToComplete, JsonToken token, JsonContainerType Type, CancellationToken CancellationToken)
|
||||||
{
|
{
|
||||||
await task;
|
await task.ConfigureAwait(false);
|
||||||
|
|
||||||
// Finish current loop
|
// Finish current loop
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ namespace Newtonsoft.Json
|
|||||||
|
|
||||||
async Task AwaitEnd(Task task, int LevelsToComplete, JsonContainerType Type, CancellationToken CancellationToken)
|
async Task AwaitEnd(Task task, int LevelsToComplete, JsonContainerType Type, CancellationToken CancellationToken)
|
||||||
{
|
{
|
||||||
await task;
|
await task.ConfigureAwait(false);
|
||||||
|
|
||||||
// Finish current loop
|
// Finish current loop
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
var t = writer.WriteStartObjectAsync(cancellationToken);
|
var t = writer.WriteStartObjectAsync(cancellationToken);
|
||||||
if (!t.IsCompletedSucessfully())
|
if (!t.IsCompletedSucessfully())
|
||||||
{
|
{
|
||||||
return AwaitStartObject(t, writer, cancellationToken, converters);
|
return AwaitProperties(t, 0, writer, cancellationToken, converters);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _properties.Count; i++)
|
for (int i = 0; i < _properties.Count; i++)
|
||||||
@@ -59,22 +59,9 @@ namespace Newtonsoft.Json.Linq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t = writer.WriteEndObjectAsync(cancellationToken);
|
return writer.WriteEndObjectAsync(cancellationToken);
|
||||||
|
|
||||||
return (t.IsCompletedSucessfully()) ? AsyncUtils.CompletedTask : AwaitEndObject(t);
|
|
||||||
|
|
||||||
// Local functions, params renamed (capitalized) so as not to capture and allocate when calling async
|
// Local functions, params renamed (capitalized) so as not to capture and allocate when calling async
|
||||||
async Task AwaitStartObject(Task task, JsonWriter Writer, CancellationToken CancellationToken, JsonConverter[] Converters)
|
|
||||||
{
|
|
||||||
await task.ConfigureAwait(false);
|
|
||||||
for (int i = 0; i < _properties.Count; i++)
|
|
||||||
{
|
|
||||||
await _properties[i].WriteToAsync(Writer, CancellationToken, Converters).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Writer.WriteEndObjectAsync(CancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
async Task AwaitProperties(Task task, int i, JsonWriter Writer, CancellationToken CancellationToken, JsonConverter[] Converters)
|
async Task AwaitProperties(Task task, int i, JsonWriter Writer, CancellationToken CancellationToken, JsonConverter[] Converters)
|
||||||
{
|
{
|
||||||
await task.ConfigureAwait(false);
|
await task.ConfigureAwait(false);
|
||||||
@@ -85,11 +72,6 @@ namespace Newtonsoft.Json.Linq
|
|||||||
|
|
||||||
await Writer.WriteEndObjectAsync(CancellationToken).ConfigureAwait(false);
|
await Writer.WriteEndObjectAsync(CancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task AwaitEndObject(Task task)
|
|
||||||
{
|
|
||||||
await task.ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user