Skip to content

Commit c23efa8

Browse files
committed
SimpleCommandProcessor: tasks queue management improved
1 parent 994ac40 commit c23efa8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/SimpleCommandProcessor.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Xtensive.Orm.Providers
1414
{
1515
internal sealed class SimpleCommandProcessor : CommandProcessor, ISqlTaskProcessor
1616
{
17-
private readonly Queue<SqlTask> tasks;
17+
private Queue<SqlTask> tasks = new();
1818

1919
void ISqlTaskProcessor.ProcessTask(SqlLoadTask task, CommandProcessorContext context)
2020
{
@@ -51,8 +51,8 @@ void ISqlTaskProcessor.ProcessTask(SqlPersistTask task, CommandProcessorContext
5151

5252
public override void ExecuteTasks(CommandProcessorContext context)
5353
{
54-
context.ProcessingTasks = new Queue<SqlTask>(tasks);
55-
tasks.Clear();
54+
context.ProcessingTasks = tasks;
55+
tasks = new Queue<SqlTask>();
5656

5757
while (context.ProcessingTasks.Count > 0) {
5858
AllocateCommand(context);
@@ -79,8 +79,8 @@ public override void ExecuteTasks(CommandProcessorContext context)
7979

8080
public override async Task ExecuteTasksAsync(CommandProcessorContext context, CancellationToken token)
8181
{
82-
context.ProcessingTasks = new Queue<SqlTask>(tasks);
83-
tasks.Clear();
82+
context.ProcessingTasks = tasks;
83+
tasks = new Queue<SqlTask>();
8484

8585
while (context.ProcessingTasks.Count > 0) {
8686
AllocateCommand(context);
@@ -152,7 +152,6 @@ private void ValidateCommandParameters(CommandPart commandPart)
152152
public SimpleCommandProcessor(CommandFactory factory, int maxQueryParameterCount)
153153
: base(factory, maxQueryParameterCount)
154154
{
155-
tasks = new Queue<SqlTask>();
156155
}
157156
}
158157
}

0 commit comments

Comments
 (0)