tags:

views:

344

answers:

3
A: 

I use Port Drivers myself for the case you are describing (haven't touched the C nodes because I'd rather have more decoupling).

Have a look at the Port Driver library for Erlang: EPAPI. There is a project that leverages this library: Erland DBus.

jldupont
The problem is that the producer will be the C node and the Erlang Node will be the consumer. I've considered the idea of using a port, but calling in a continuous loop the port driver's service doesn't seem the best way to do this.
@zalmoxis: there are many different ways to address this situation, one of which might be to use a "token based credit algorithm". The "consumer node" sends "credits" to the producer node. Each "send" requires a "credit": when there is no more, the "producer" must wait for a next "delivery" of credits.
jldupont
@zalmoxis: the "token based shaper" I describe above can easily be implemented on the "producer" side (written in C) whilst it is equally trivial to add support for this scheme on the Erlang side. Since you are already for "pain" using "C nodes", then I know you can take on Port Drivers. Cheers and have fun! ( anyhow, as always, consider my contribution as a suggestion for your consideration ).
jldupont
A: 

Did you check the ei_receive_msg_tmo function? I suppose it works similar to the receive after construct of Erlang, so if you set timeout to 0, it will be non-blocking.

I believe erl_interface is deprecated, and ei should be used instead. This might be a complete misinformation though...

Zed
Thanks, I am currently testing it. Please note that by calling ei_receive_msg_tmo with timeout 0 it will become blocking.
Okay. So apparently the non-timeout functions fall back to the timeout ones with ms=0. That's why ms=0 becomes blocking (seethe ei_read_t() function erl_interface/src/misc/ei_portio.c). I would call this a victory of laziness over functionality :)
Zed
A: 

you need to take a closer look at the tutorial link that you posted. (search for "And finally we have the code for the C node client.") You will see that the author provided a client cnode implementation. It looks rational.

Richard