-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add timer:send_interval/3 #37
Comments
This would be the implementation, similar to @external(erlang, "timer", "send_interval")
fn timer_send_interval(a: Int, b: Pid, c: msg) -> Timer
pub fn send_interval(subject: Subject(msg), delay: Int, message: msg) -> Timer {
timer_send_interval(delay, subject.owner, #(subject.tag, message))
} |
Could be cool! Is there a reason not to use send_after? It can help avoid overloading a process, but I guess most the time that's not a risk. |
|
You'd use It's not that the timer is expensive, it's that if you ever take too long to handle a tick message you end up with multiple tick messages in the inbox, potentially never managing to catch up resulting in the inbox growing. This then has performance implications and any other messages sent may have delay before they are handled. With We could add this function, but I think |
Can we add timer:send_interval/3 to
gleam/erlang/process
?It behaves similarly to
send_after
, except it spins up a process that repeatedly sends the message every time interval. It's useful for a low-fidelityTick
.Since
Subject(a)
is opaque, I can't implement it myself in projects without resorting to FFI workarounds unpacking the Subject tuple by hand.The text was updated successfully, but these errors were encountered: