Skip to content

Commit a05b336

Browse files
bahusoidhazzik
authored andcommitted
Use generic parameters in ActionQueue
1 parent cf930a5 commit a05b336

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/NHibernate/Async/Engine/ActionQueue.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System;
1212
using System.Collections;
1313
using System.Collections.Generic;
14-
using System.Linq;
1514
using System.Text;
1615
using System.Threading;
1716
using System.Threading.Tasks;
@@ -24,15 +23,14 @@ namespace NHibernate.Engine
2423
public partial class ActionQueue
2524
{
2625

27-
private async Task ExecuteActionsAsync(IList list, CancellationToken cancellationToken)
26+
private async Task ExecuteActionsAsync<T>(List<T> list, CancellationToken cancellationToken) where T: IExecutable
2827
{
2928
cancellationToken.ThrowIfCancellationRequested();
3029
// Actions may raise events to which user code can react and cause changes to action list.
3130
// It will then fail here due to list being modified. (Some previous code was dodging the
3231
// trouble with a for loop which was not failing provided the list was not getting smaller.
3332
// But then it was clearing it without having executed added actions (if any), ...)
34-
35-
foreach (IExecutable executable in list)
33+
foreach (var executable in list)
3634
{
3735
await (InnerExecuteAsync(executable, cancellationToken)).ConfigureAwait(false);
3836
}
@@ -118,10 +116,10 @@ public async Task ExecuteActionsAsync(CancellationToken cancellationToken)
118116
}
119117
}
120118

121-
private static async Task PrepareActionsAsync(IList queue, CancellationToken cancellationToken)
119+
private static async Task PrepareActionsAsync<T>(List<T> queue, CancellationToken cancellationToken) where T: IExecutable
122120
{
123121
cancellationToken.ThrowIfCancellationRequested();
124-
foreach (IExecutable executable in queue)
122+
foreach (var executable in queue)
125123
await (executable.BeforeExecutionsAsync(cancellationToken)).ConfigureAwait(false);
126124
}
127125

src/NHibernate/Engine/ActionQueue.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4-
using System.Linq;
54
using System.Text;
65
using System.Threading;
76
using System.Threading.Tasks;
@@ -156,14 +155,13 @@ public void RegisterProcess(AfterTransactionCompletionProcessDelegate process)
156155
RegisterProcess(new AfterTransactionCompletionDelegatedProcess(process));
157156
}
158157

159-
private void ExecuteActions(IList list)
158+
private void ExecuteActions<T>(List<T> list) where T: IExecutable
160159
{
161160
// Actions may raise events to which user code can react and cause changes to action list.
162161
// It will then fail here due to list being modified. (Some previous code was dodging the
163162
// trouble with a for loop which was not failing provided the list was not getting smaller.
164163
// But then it was clearing it without having executed added actions (if any), ...)
165-
166-
foreach (IExecutable executable in list)
164+
foreach (var executable in list)
167165
{
168166
InnerExecute(executable);
169167
}
@@ -258,9 +256,9 @@ public void ExecuteActions()
258256
}
259257
}
260258

261-
private static void PrepareActions(IList queue)
259+
private static void PrepareActions<T>(List<T> queue) where T: IExecutable
262260
{
263-
foreach (IExecutable executable in queue)
261+
foreach (var executable in queue)
264262
executable.BeforeExecutions();
265263
}
266264

@@ -329,9 +327,9 @@ public bool AreInsertionsOrDeletionsQueued
329327
get { return (insertions.Count > 0 || deletions.Count > 0); }
330328
}
331329

332-
private static bool AreTablesToUpdated(IList executables, ICollection<string> tablespaces)
330+
private static bool AreTablesToUpdated<T>(List<T> executables, ISet<string> tablespaces) where T: IExecutable
333331
{
334-
foreach (IExecutable exec in executables)
332+
foreach (var exec in executables)
335333
{
336334
var spaces = exec.PropertySpaces;
337335
foreach (string o in spaces)

0 commit comments

Comments
 (0)