Process A sends a request to B after 1 minute with send_after (let's call it request). But B has 1 minute to cancel it.
Can B send cancel to A and prevent that message being sent within this timespan?
Yes you can.
When you are using erlang:send_after it returns a TimerRef.
If you want to cancel the request you just need to call erlang:cancel_timer(TimerRef) or erlang:cancel_timer(TimerRef, Options).
In your case, if you want process B to cancel the message you will have to send TimerRef from A to B and then call erlang:cancel_timer(TimerRef) in process B in order to cancel this specific send request.
Please take a look at erlang documentation erlang:cancel_timer/2 for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With