ERLANG wait()和阻塞 [英] ERLANG wait() and blocking

查看:128
本文介绍了ERLANG wait()和阻塞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



一个很好的答案将详细介绍erlang和/或cpu的内部工作。

  wait(Sec) - > 
在(1000 * Sec)之后收到
- > ok
结束。


解决方案

执行该代码块,运行该进程的调度程序当前将不会阻止。您发布的代码等于产量,但是超时。



该核心的Erlang VM调度程序将继续执行其他进程,直到超时触发并且该进程将被安排再次执行。


Does the following function block on its running core?

A great answer will detail the internal working of erlang and/or the cpu.

wait(Sec) -> 
    receive
    after (1000 * Sec) -> ok
    end.

解决方案

The process which executes that code will block, the scheduler which runs that process currently will not block. The code you posted is equal to a yield, but with a timeout.

The Erlang VM scheduler for that core will continue to execute other processes until that timeout fires and that process will be scheduled for execution again.

这篇关于ERLANG wait()和阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆