Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Novotny committed Aug 15, 2016
1 parent 26d1cea commit 3ece9f4
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions Ix.NET/Source/System.Interactive.Async/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ public static IAsyncEnumerable<T> CreateEnumerable<T>(Func<IAsyncEnumerator<T>>

public static IAsyncEnumerator<T> CreateEnumerator<T>(Func<CancellationToken, Task<bool>> moveNext, Func<T> current, Action dispose)
{
return new AnonymousAsyncIterator<T>(moveNext, current, dispose, null);
}

private static IAsyncEnumerator<T> CreateEnumerator<T>(Func<CancellationToken, Task<bool>> moveNext, Func<T> current,
Action dispose, IDisposable enumerator)
{
return new AnonymousAsyncIterator<T>(moveNext, current, dispose, enumerator);
return new AnonymousAsyncIterator<T>(moveNext, current, dispose);
}

private static IAsyncEnumerator<T> CreateEnumerator<T>(Func<CancellationToken, TaskCompletionSource<bool>, Task<bool>> moveNext, Func<T> current, Action dispose)
Expand All @@ -49,8 +43,7 @@ private static IAsyncEnumerator<T> CreateEnumerator<T>(Func<CancellationToken, T
}
},
current,
dispose,
null
dispose
);
return self;
}
Expand All @@ -76,16 +69,14 @@ private sealed class AnonymousAsyncIterator<T> : AsyncIterator<T>
{
private readonly Func<T> currentFunc;
private readonly Action dispose;
private IDisposable enumerator;
private readonly Func<CancellationToken, Task<bool>> moveNext;


public AnonymousAsyncIterator(Func<CancellationToken, Task<bool>> moveNext, Func<T> currentFunc, Action dispose, IDisposable enumerator)
public AnonymousAsyncIterator(Func<CancellationToken, Task<bool>> moveNext, Func<T> currentFunc, Action dispose)
{
this.moveNext = moveNext;
this.currentFunc = currentFunc;
this.dispose = dispose;
this.enumerator = enumerator;

// Explicit call to initialize enumerator mode
GetEnumerator();
Expand All @@ -98,11 +89,6 @@ public override AsyncIterator<T> Clone()

public override void Dispose()
{
if (enumerator != null)
{
enumerator.Dispose();
enumerator = null;
}
dispose?.Invoke();

base.Dispose();
Expand Down

0 comments on commit 3ece9f4

Please sign in to comment.