Polling a CNODE

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Polling a CNODE

Damien Towning
Hi Everyone, 

I have a cnode written in C that performs some complex geometrical operations. The code is non blocking but I am wondering what the best way is to establish a keep alive poll back as return time for the cnode could be anywhere from a few seconds to hours. The cnode on the Erlang side is in elixir but I think this is really more an Erlang question than an Elixir one. I have something like this 
on the Erlang/Elixir side 

 Nodex.Distributed.up()
    {conn, pid} = Cnode.start_link(%{exec_path: "bin/brep" , spawn_inactive_timeout: :infinity } )
 Cnode.call(pid, msg  )

And then something like this on the c code side 

 else if ( erl_match(erl_format("blah"),operation) ) { 
    std::vector<double> para(3); 
    ETERM *parameters = erl_element(2,emsg->msg);
    para = list_to_vectors( parameters ); 
    cylinder(para[0],para[1],para[2]);  
    response = erl_mk_int( geometry.currentIndex() ); 
    erl_free_term(parameters);
  }

My code does not block and I can regularly send messages back. I am just not sure what to send back as a regular wake up call. 

 

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Polling a CNODE

Robert Raschke
I don't have the docs in front of me at the moment, but if I remember correctly you need to have the message receive loop running continuously, which handles the inter Erlang node pings for you. You can then monitor the C node from Elixir and get a message if a ping was not answered in a timely fashion.

On Mon, 3 Sep 2018 13:27 Damien Towning, <[hidden email]> wrote:
Hi Everyone, 

I have a cnode written in C that performs some complex geometrical operations. The code is non blocking but I am wondering what the best way is to establish a keep alive poll back as return time for the cnode could be anywhere from a few seconds to hours. The cnode on the Erlang side is in elixir but I think this is really more an Erlang question than an Elixir one. I have something like this 
on the Erlang/Elixir side 

 Nodex.Distributed.up()
    {conn, pid} = Cnode.start_link(%{exec_path: "bin/brep" , spawn_inactive_timeout: :infinity } )
 Cnode.call(pid, msg  )

And then something like this on the c code side 

 else if ( erl_match(erl_format("blah"),operation) ) { 
    std::vector<double> para(3); 
    ETERM *parameters = erl_element(2,emsg->msg);
    para = list_to_vectors( parameters ); 
    cylinder(para[0],para[1],para[2]);  
    response = erl_mk_int( geometry.currentIndex() ); 
    erl_free_term(parameters);
  }

My code does not block and I can regularly send messages back. I am just not sure what to send back as a regular wake up call. 

 
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions