Receive/until and support for absolute timeouts (Deadlines)

Today erlang has a receive/after construct that allows to wait for a message with a timeout. Given that gen_server/statem added support for absolute timeouts (deadlines) in OTP 24, and erlang:start_timer had it since 18? Would it make sense to consider a receive/until construct that makes use of deadlines?

In general, I feel at times that the overall support for timeouts would be greatly improved with the addition of deadlines.


1 Like

What’s wrong with
receive …
after milliseconds_to(Deadline) → …
where milliseconds_to is a function that takes the time expressed in the clock and units of your preference and subtracts the time now expressed in the clock and units of your preference?

In the presence of time warping clocks, it’s not clear to me what waiting until an absolute deadline means unless you spell it out in painstaking detail, and with there being more than one way to do it, I think it is best to avoid revising the syntax until there is some sort of consensus on what the semantics should be.


You are absolutely right regarding the syntax, that would be quite unnecessary as you clearly pointed out.

Thank you for your reply.