You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.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
The text was updated successfully, but these errors were encountered:
I didn't mean to ask you to create a patch before the discussion about API, I wanted to know what you are imagining it would look like if it were expressed as an API in Rust.
I guess what you are actually requesting here is something like tokio::time::interval, but tokio::time::interval also has an API to tune the behavior.
Yes, it seems like tokio::time::interval while I don't find your comment "has an API to tune the behavior". It seems that struct has only a period arg to define the interval.
For API in crossbeam channel, the whole structure can be identical to tick with different rules for calculating delivery_time, i.e.,
for try_recv, it's delivery_time + self.duration over now + self.duration.
for recv, it's delivery_time + self.duration over delivery_time.max(now) + self.duration.
If we agree on reuse the structure, it can be a different API on crossbeam_channel to switch the flavor,
Currently, the new delivery_time is calculated as:
crossbeam/crossbeam-channel/src/flavors/tick.rs
Lines 47 to 50 in dfafb46
But it can be a flavor config like Java's
ScheduledExecutorService
:scheduleAtFixedRate
andscheduleWithFixedDelay
.The current flavor is in
scheduleWithFixedDelay
, while replacenow + self.duration
withdelivery_time + self.duration
can simulatescheduleAtFixedRate
as much as possible.To consume multiple ticks backlog, one can use
try_iter
and thencollect
.Let me know if it's a good idea to follow. cc @taiki-e
The text was updated successfully, but these errors were encountered: