有没有更好的方法在Erlang OTP 22中编写定时器[关闭]

4smxwvx5  于 7个月前  发布在  Erlang
关注(0)|答案(1)|浏览(70)

已关闭。此问题需要details or clarity。目前不接受回答。
**要改进此问题吗?**通过editing this post添加详细信息并阐明问题。

11天前关闭
Improve this question
如何用Erlang写一个计时器,它是如何工作的?
例如,我试图理解这段代码:

Function ({deliver_sm, Number, Time}) when Time == "Deliverd" -> 

      timer:sleep(600000),

      #what happens when number and time comes here from another node. It's like a parent and child. I have received a submit request from one node and I have to delay the node where it will send a response which is this deliver sm.

字符串
我已经尝试使用这个定时器睡眠,但功能工作正常,没有被置于睡眠状态。有没有办法知道,这个睡眠定时器的工作。例如,我可以打印时间时,这个定时器被触发。或者我是在一个错误的方向?任何建议,欢迎和谢谢你

gijlo24d

gijlo24d1#

我可以打印这个计时器被触发的时间。

do_stuff({deliver_sm, Number, Time}) when Time == "Deliverd" -> 

      io:format("Time just before timer was triggered: ~w~n", [erlang:system_time()]), 
      timer:sleep(600000),
      io:format("Time after sleeping: ~w~n", [erlang:system_time()]).

字符串

相关问题