Skip to content

crossbeam_channel::tick delivery_time can support different flavor #989

Open
@tisonkun

Description

@tisonkun

Currently, the new delivery_time is calculated as:

if self
.delivery_time
.compare_exchange(delivery_time, now + self.duration)
.is_ok()

But it can be a flavor config like Java's ScheduledExecutorService: scheduleAtFixedRate and scheduleWithFixedDelay.

The current flavor is in scheduleWithFixedDelay, while replace now + self.duration with delivery_time + self.duration can simulate scheduleAtFixedRate as much as possible.

To consume multiple ticks backlog, one can use try_iter and then collect.

Let me know if it's a good idea to follow. cc @taiki-e

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions