I have written a library that supports publish/subscribe messaging and has already converted it to ROOT compatible interfaces. The ROOT interpreted code calls the Subscribe() method in the library passing a function pointer(callback function) and waits.
Once a message is received, this function gets called by the library. I am using CINT’s G__CallFunc interface to achieve the above as pointed out by Axel in a previous discussion. root.cern.ch/phpBB2/viewtopic.php?t=5408
The Subscribe() method uses a pthread internally so the caller should wait till it returns.
Now I am trying to update a histogram using the data received via the subscription messages.
Everything works as expected when I use the following two lines to stop the interpreted code from exiting after calling Subscribe() method in the library.
But, this will simply freeze the user interface and the histogram on the canvas get erased if another windows comes in front.
I tried the following, only for the GUI and it works fine as shown by Ilka (root.cern.ch/phpBB2/viewtopic.php?t=5655)
However, this does not work when the GUI is integrated with the publish/subscribe library. It gives a segmentation violation error.
I even tried using a custom wait function which utilize “usleep()” of C++ but still it crashes when the callback function get called from the library.
This is how I call the callback function from the compiled code.
G__ClassInfo *cl=new C__ClassInfo(className);
sprintf(temp,"(void **)%-p,(char *)%-p,(int)%d",this->tCallback->getArgs(),payload,payloadSize);
Could someone please help me to figure out a possible solution to this?
The Subscribe() function takes a function pointer from the interpreted code and call that function when a message is received by the