Skip to content

Commit 3226be3

Browse files
committed
Get rid of OperationData
1 parent d8ef7b8 commit 3226be3

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

Mono.Debugging/Mono.Debugging.Evaluation/AsyncOperationManager.cs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,7 @@ namespace Mono.Debugging.Evaluation
3535
{
3636
public class AsyncOperationManager : IDisposable
3737
{
38-
class OperationData
39-
{
40-
public IAsyncOperationBase Operation { get; private set; }
41-
public OperationData (IAsyncOperationBase operation)
42-
{
43-
Operation = operation;
44-
}
45-
}
46-
47-
readonly HashSet<OperationData> currentOperations = new HashSet<OperationData> ();
38+
readonly HashSet<IAsyncOperationBase> currentOperations = new HashSet<IAsyncOperationBase> ();
4839
bool disposed = false;
4940
const int ShortCancelTimeout = 100;
5041

@@ -70,13 +61,12 @@ public OperationResult<TValue> Invoke<TValue> (AsyncOperationBase<TValue> mc, in
7061

7162
Task<OperationResult<TValue>> task;
7263
var description = mc.Description;
73-
var operationData = new OperationData (mc);
7464
lock (currentOperations) {
7565
if (disposed)
7666
throw new ObjectDisposedException ("Already disposed");
7767
DebuggerLoggingService.LogMessage (string.Format("Starting invoke for {0}", description));
7868
task = mc.InvokeAsync ();
79-
currentOperations.Add (operationData);
69+
currentOperations.Add (mc);
8070
}
8171

8272
bool cancelledAfterTimeout = false;
@@ -111,7 +101,7 @@ public OperationResult<TValue> Invoke<TValue> (AsyncOperationBase<TValue> mc, in
111101
}
112102
finally {
113103
lock (currentOperations) {
114-
currentOperations.Remove (operationData);
104+
currentOperations.Remove (mc);
115105
}
116106
}
117107
}
@@ -151,7 +141,7 @@ void WaitAfterCancel (IAsyncOperationBase op)
151141
public void AbortAll ()
152142
{
153143
DebuggerLoggingService.LogMessage ("Aborting all the current invocations");
154-
List<OperationData> copy;
144+
List<IAsyncOperationBase> copy;
155145
lock (currentOperations) {
156146
if (disposed) throw new ObjectDisposedException ("Already disposed");
157147
copy = currentOperations.ToList ();
@@ -161,14 +151,14 @@ public void AbortAll ()
161151
CancelOperations (copy, true);
162152
}
163153

164-
void CancelOperations (List<OperationData> operations, bool wait)
154+
void CancelOperations (List<IAsyncOperationBase> operations, bool wait)
165155
{
166-
foreach (var operationData in operations) {
167-
var taskDescription = operationData.Operation.Description;
156+
foreach (var operation in operations) {
157+
var taskDescription = operation.Description;
168158
try {
169-
operationData.Operation.Abort ();
159+
operation.Abort ();
170160
if (wait) {
171-
WaitAfterCancel (operationData.Operation);
161+
WaitAfterCancel (operation);
172162
}
173163
}
174164
catch (Exception e) {
@@ -185,7 +175,7 @@ void CancelOperations (List<OperationData> operations, bool wait)
185175

186176
public void Dispose ()
187177
{
188-
List<OperationData> copy;
178+
List<IAsyncOperationBase> copy;
189179
lock (currentOperations) {
190180
if (disposed) throw new ObjectDisposedException ("Already disposed");
191181
disposed = true;

0 commit comments

Comments
 (0)