Skip to content

[POC] Streamline IWithTimers API #7741

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

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Arkatufus
Copy link
Contributor

Discussing #7644

A POC to address IWithTimers

Changes

  • Remove IWithTimers
  • Timers are accessed directly from the ActorContext (ActorCell)
  • Timers are created lazily
  • Instead of using obj is IWithTimers check, we use Context.HaveTimers instead (mechanism can always be changed)

@Arkatufus Arkatufus added the NO MERGE Don't merge. label Aug 7, 2025
@Arkatufus Arkatufus changed the title [POC] Streamline IWithTimers [POC] Streamline IWithTimers API Aug 7, 2025
Copy link
Contributor Author

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

self-review

Comment on lines +157 to +168

private ITimerScheduler? _timers;

public ITimerScheduler Timers
{
get
{
return _timers ??= new TimerScheduler(this);
}
}

public bool HaveTimers => _timers is not null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actual change, we move the timer into ActorCell itself, which is what being used as ActorContext inside actor message handlers. The timers instace is created lazily to save memory consuption.

The HaveTimers property is needed for cleanup purposes, we can always change this to internal

@Arkatufus
Copy link
Contributor Author

DocFX test failing because we delete IWithTimers, which is still being referenced in the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NO MERGE Don't merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant