3
votes

For example, right now I have a C Node (call it CN) which connects to an erlang node (call it EN) and uses a RPC to use OTP behaviors. Hence, to send an event from CN to an event manager on EN I connect CN to EN and do

args = erl_format("[data_man, {~f, ~f}]", ch.at(0), ch.at(1));
erl_rpc_to(fd, "gen_event", "notify", args);

But, then, my C Node really isn't behaving as a node (i.e. why create a node that only uses remote procedure calls?).

Is there a way to directly use OTP behaviors within a C Node?

If there isn't, should I look under the hood at the message formats being used by OTP and send messages using that format (i.e. can I spoof OTP behaviors?)? I don't like this idea, I'll have to watch for changes in the implementation of OTP etc.

I have hard latency limits in my requirements, how does this effect my choice of communication between a C process and Erlang (are RPCs going to bog me down? etc.)?

1

1 Answers

4
votes

There is no way to directly use OTP behaviours from C. I also don't think you should mimic the OTP behaviours to use them directly.

You should just first use RPC and then test your code against your performance requirements. If needed, you could always send a simple message to your gen_event process to make it notify itself through its handle_info/2 method.