Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 Erlang 的新手,我想暂停一个函数。我使用无限超时接收,我的函数如下所示:
suspend() -> receive after infinity->ok end.
当我运行透析器工具时,它返回“函数没有本地返回”。我应该用 timer:sleep(infinity) 替换这个函数吗?对于暂停,哪个更好?太感谢了。
函数timer:sleep/1定义为:
timer:sleep/1
sleep(T) -> receive after T -> ok end.
这与您的功能基本相同suspend/0,因此任何一种方法都可以。不过,我建议使用timer:sleep/1,因为它已经为您定义了,任何阅读它的人都会立即知道它是什么以及它的作用。
suspend/0