Domanda

Can we communicate with erl_nif thread created and normal erlang process? We can send messages from nif thread to erlang process using nif_send but can nif thread receive messages from any erlang process like normal erlang process do?

È stato utile?

Soluzione

No, a thread created with enif_thread_create is not an Erlang process and cannot receive messages.

You are probably trying to achieve too much with your NIF and might consider writing a linked in driver instead, which can send messages and receive messages from Erlang.

Alternatively, you could use a conditional variable and/or a pipe in your native thread to wait for an event which would be generated by a NIF function called from the emulator whenever the message you are expecting is received. Indeed, unlike linked in drivers, you cannot use the select interface from the emulator.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top