Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@stephentoub
Copy link
Member

When CancellationTokenSource creates a Timer, it passes itself as state, which then results in the Timer being rooted while it's scheduled. As such, the Timer object itself and the TimerHolder object it creates are largely irrelevant, and since CancellationTokenSource has access, it can just create the underlying TimerQueueTimer object directly. This means that every CTS that creates a Timer now creates two fewer objects, one of which was finalizable.

cc: @kouvel, @tarekgh

When CancellationTokenSource creates a Timer, it passes itself as state, which then results in the Timer being rooted while it's scheduled.  As such, the Timer object itself and the TimerHolder object it creates are largely irrelevant, and since CancellationTokenSource has access, it can just create the underlying TimerQueueTimer object directly.  This means that every CTS that creates a Timer now creates two fewer objects, one of which was finalizable.
@stephentoub stephentoub added this to the 3.0 milestone Oct 21, 2018
@stephentoub
Copy link
Member Author

@dotnet-bot test this please

@stephentoub stephentoub merged commit 628df38 into dotnet:master Oct 22, 2018
@stephentoub stephentoub deleted the ctstimeralloc branch October 22, 2018 18:28
A-And pushed a commit to A-And/coreclr that referenced this pull request Nov 20, 2018
…dotnet#20509)

When CancellationTokenSource creates a Timer, it passes itself as state, which then results in the Timer being rooted while it's scheduled.  As such, the Timer object itself and the TimerHolder object it creates are largely irrelevant, and since CancellationTokenSource has access, it can just create the underlying TimerQueueTimer object directly.  This means that every CTS that creates a Timer now creates two fewer objects, one of which was finalizable.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…dotnet/coreclr#20509)

When CancellationTokenSource creates a Timer, it passes itself as state, which then results in the Timer being rooted while it's scheduled.  As such, the Timer object itself and the TimerHolder object it creates are largely irrelevant, and since CancellationTokenSource has access, it can just create the underlying TimerQueueTimer object directly.  This means that every CTS that creates a Timer now creates two fewer objects, one of which was finalizable.

Commit migrated from dotnet/coreclr@628df38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants