Skip to content

Remove ActorTimers, and offer task-cancellation and async aware alternative #958

@ktoso

Description

@ktoso

Depends on apple/swift-async-algorithms#165 Remove the disable of availability and mark methods as available to clock/instant/duration


The ActorTimers cannot easily participate in task cancellation and structured concurrency; we should make use of https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Timer.md rather than Dispatch -- or rather, end users should be doing this and their TASKS get cancelled, not really actors as they used to in the old behavior world.

This is also the next step of #955 Replace our own TimeAmount with Swift.Duration as it simplifies our reliance on those time types.

Probably timers instead, now, thanks to actor re-entrance, tasks and the new Timer inside swift-algorithms is really more of a pattern:

Task { 
  for await tick in AsyncTimerSequence.repeating(every: duration) {
    // ... 
    try await receptionist.pushOps(...)
  }
}

so this would get cancelled as we decide to cancel the system... we'd have a cancel() on the receptionist...

We don't need to make any new ActorTimers at all I think?

Metadata

Metadata

Assignees

Labels

3 - in progressTicket is being worked onsize/SSmall task. (A couple of hours of work.)t:timers

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions