@@ -41,32 +41,27 @@ void process_body(std::string &node_ser, int read_fd, int send_fd, bool isMultiO
4141 py_ff_callback_object* callback = (py_ff_callback_object*) PyObject_CallObject (
4242 (PyObject *) &py_ff_callback_type, NULL
4343 );
44- callback->ff_send_out_to_callback = [isMultiOutput, &pickl, &messaging](PyObject* pydata, int index) {
44+ callback->ff_send_out_callback = [isMultiOutput, &pickl, &messaging](PyObject* pydata, int index) {
4545 if (!isMultiOutput) {
4646 PyErr_SetString (PyExc_Exception, " Operation not available. This is not a multi output node" );
4747 return (PyObject*) NULL ;
4848 }
4949
50- if (index < 0 ) {
51- PyErr_SetString (PyExc_Exception, " Index cannot be negative" );
52- return (PyObject*) NULL ;
53- }
54-
5550 Message response;
5651 if (PyObject_TypeCheck (pydata, &py_ff_constant_type) != 0 ) {
5752 // we may have a fastflow constant as data to send out to index
5853 py_ff_constant_object* _const_result = reinterpret_cast <py_ff_constant_object*>(pydata);
59- int err = messaging.call_remote (response, " ff_send_out_to " , index, _const_result->ff_const );
54+ int err = messaging.call_remote (response, " ff_send_out " , _const_result->ff_const , index );
6055 if (err <= 0 ) {
61- PyErr_SetString (PyExc_Exception, " Error occurred sending ff_send_out_to request" );
56+ PyErr_SetString (PyExc_Exception, " Error occurred sending ff_send_out request" );
6257 return (PyObject*) NULL ;
6358 }
6459 } else {
6560 auto data = pickl.pickle (pydata);
66- int err = messaging.call_remote (response, " ff_send_out_to " , index, data );
61+ int err = messaging.call_remote (response, " ff_send_out " , data, index );
6762 if (PyErr_Occurred ()) return (PyObject*) NULL ;
6863 if (err <= 0 ) {
69- PyErr_SetString (PyExc_Exception, " Error occurred sending ff_send_out_to request" );
64+ PyErr_SetString (PyExc_Exception, " Error occurred sending ff_send_out request" );
7065 return (PyObject*) NULL ;
7166 }
7267 }
@@ -81,7 +76,7 @@ void process_body(std::string &node_ser, int read_fd, int send_fd, bool isMultiO
8176 CHECK_ERROR_THEN (" PyDict_SetItemString failure: " , cleanup_exit ();)
8277 }
8378 // if you access the methods by importing them from the module, replace each method with the delegate's one
84- if (PyDict_SetItemString (globals, " ff_send_out_to " , PyObject_GetAttrString ((PyObject*) callback, " ff_send_out_to " )) == -1 ) {
79+ if (PyDict_SetItemString (globals, " ff_send_out " , PyObject_GetAttrString ((PyObject*) callback, " ff_send_out " )) == -1 ) {
8580 CHECK_ERROR_THEN (" PyDict_SetItemString failure: " , cleanup_exit ();)
8681 }
8782
@@ -248,23 +243,27 @@ class base_process {
248243
249244 while (response.type == MESSAGE_TYPE_REMOTE_PROCEDURE_CALL) {
250245 // the only supported remote procedure call from the child process
251- // if the call of ff_send_out_to (as of today...)
252- if (response.f_name .compare (" ff_send_out_to " ) != 0 ) {
246+ // if the call of ff_send_out (as of today...)
247+ if (response.f_name .compare (" ff_send_out " ) != 0 ) {
253248 handleError (" got invalid f_name" , );
254249 return NULL ;
255250 }
256251
257- // parse received ff_send_out_to request
258- std::tuple<int , std::string> args = messaging.parse_data <int , std::string>(response.data );
252+ // parse received ff_send_out request
253+ std::tuple<std::string, int > args = messaging.parse_data <std::string, int >(response.data );
259254 // try to deserialize to constant. If it results into NULL, then it is NOT a FastFlow's constant
260- void * constant = deserialize<void *>(std::get<1 >(args));
261- // finally perform ff_send_out_to
262- bool result = registered_callback->ff_send_out_to (constant == NULL ? (void *) new std::string (std::get<1 >(args)):constant, std::get<0 >(args));
255+ void * constant = deserialize<void *>(std::get<0 >(args));
256+ // finally perform ff_send_out
257+ int index = std::get<1 >(args);
258+ auto data = constant == NULL ? (void *) new std::string (std::get<0 >(args)):constant;
259+ bool result = index >= 0 ?
260+ registered_callback->ff_send_out_to (data, index):
261+ registered_callback->ff_send_out (data);
263262
264- // send ff_send_out_to result
263+ // send ff_send_out result
265264 err = messaging.send_response (result);
266265 if (err <= 0 ) {
267- handleError (" error sending ff_send_out_to response" , );
266+ handleError (" error sending ff_send_out response" , );
268267 return NULL ;
269268 }
270269
0 commit comments