Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 6 additions & 29 deletions Rx.NET/Source/src/System.Reactive/Internal/Producer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public IDisposable SubscribeRaw(IObserver<TSource> observer, bool enableSafeguar

if (CurrentThreadScheduler.IsScheduleRequired)
{
var state = new State { subscription = subscription, observer = observer };
CurrentThreadScheduler.Instance.Schedule(state, Run);
CurrentThreadScheduler.Instance.ScheduleAction(
(@this: this, subscription, observer),
tuple => tuple.subscription.Disposable = [email protected](tuple.observer));
}
else
{
Expand All @@ -62,18 +63,6 @@ public IDisposable SubscribeRaw(IObserver<TSource> observer, bool enableSafeguar
return subscription;
}

private struct State
{
public SingleAssignmentDisposable subscription;
public IObserver<TSource> observer;
}

private IDisposable Run(IScheduler _, State x)
{
x.subscription.Disposable = Run(x.observer);
return Disposable.Empty;
}

/// <summary>
/// Core implementation of the query operator, called upon a new subscription to the producer object.
/// </summary>
Expand Down Expand Up @@ -118,9 +107,9 @@ public IDisposable SubscribeRaw(IObserver<TTarget> observer, bool enableSafeguar

if (CurrentThreadScheduler.IsScheduleRequired)
{
var state = new State { sink = sink, inner = subscription.Inner };

CurrentThreadScheduler.Instance.Schedule(state, Run);
CurrentThreadScheduler.Instance.ScheduleAction(
(@this: this, sink, inner: subscription.Inner),
tuple => tuple.inner.Disposable = tuple.@this.Run(tuple.sink));
}
else
{
Expand All @@ -130,18 +119,6 @@ public IDisposable SubscribeRaw(IObserver<TTarget> observer, bool enableSafeguar
return subscription;
}

private struct State
{
public TSink sink;
public SingleAssignmentDisposable inner;
}

private IDisposable Run(IScheduler _, State x)
{
x.inner.Disposable = Run(x.sink);
return Disposable.Empty;
}

/// <summary>
/// Core implementation of the query operator, called upon a new subscription to the producer object.
/// </summary>
Expand Down