Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Improve Timer() scheduler handling #700

Merged
merged 2 commits into from
Jun 28, 2018

Conversation

akarnokd
Copy link
Collaborator

  • Use a field _index to store the value to be emitted between schedule calls.
  • Use stateful Schedule calls where appropriate.

@@ -120,6 +120,8 @@ internal sealed class _ : IdentitySink<long>
{
private readonly TimeSpan _period;

long _index;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good without volatile ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the schedulers won't execute Tick and Tock concurrently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a ForwardOnNext in both Tick and Tock, which has always required those methods to run non-concurrently with themselves and the schedulers ensure that by default. The fact that they now take the value of a field is irrelevant because reading/writing that field followed by the ForwardOnNext call still has to be non-concurrent.

@danielcweber danielcweber merged commit 837e65b into dotnet:master Jun 28, 2018
@akarnokd akarnokd deleted the TimerCleanup branch June 28, 2018 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants