【问题标题】:erl_nif_thread and erlang process communicationerl_nif_thread 和 erlang 进程通信
【发布时间】:2013-10-01 21:56:32
【问题描述】:

我们可以与创建的 erl_nif 线程和正常的 erlang 进程通信吗?我们可以使用 nif_send 从 nif 线程向 erlang 进程发送消息,但是 nif 线程可以像普通的 erlang 进程一样从任何 erlang 进程接收消息吗?

【问题讨论】:

    标签: erlang erlang-nif


    【解决方案1】:

    不,使用enif_thread_create 创建的线程不是 Erlang 进程,并且无法接收消息

    您可能试图通过您的 NIF 实现太多目标,并且可能会考虑写一个 linked in driver 来代替,它可以从 Erlang 发送消息和接收消息。

    或者,您可以在本机线程中使用条件变量和/或管道来等待一个事件,该事件将由模拟器调用的 NIF 函数在收到您期望的消息时生成。实际上,与驱动程序中的链接不同,您不能使用the select interface from the emulator

    【讨论】:

      猜你喜欢
      • 2017-08-07
      • 1970-01-01
      • 1970-01-01
      • 2012-11-21
      • 1970-01-01
      • 2014-11-09
      • 2012-05-01
      • 1970-01-01
      • 2010-12-24
      相关资源
      最近更新 更多