On 07/28/2011 10:35 PM, Cedric BAIL wrote: > As I don't want the grumpy guy that don't help. You now have > ecore_main_loop_thread_safe_call that should be the base for your > patch. And I am still not convinced that we need more than that. > People should just use that function when they are doing thread stuff > and we should advertise it in our thread spanking message.
OK, thanks for spending the time to write this. If you know you're writing code that's in a thread your function is great. Call it, and then schedule some work in the main loop, it's good. But for a library writer: 1) assume thread safety (1 line): ecore_event_add(LIB_EVENT, e, my_event_free, NULL); 2) Using ecore_main_loop_thread_safe_call (5 lines) static void _event_main_loop_callback(void *data) { ecore_event_add(LIB_EVENT, e, my_event_free, NULL); } /* will always be marshalled through pipe, even when not necessary */ ecore_main_loop_thread_safe_call(&_event_main_loop_callback, NULL); 3) Using ecore_main_loop_thread_safe_call, trying to be a bit more efficient (8 lines) static void _event_main_loop_callback(void *data) { ecore_event_add(LIB_EVENT, e, my_event_free, NULL); } if (!ecore_is_main_loop_thread()) /* assuming this function exists */ ecore_main_loop_thread_safe_call(&_event_main_loop_callback, NULL); else _event_main_loop_callback(); Case 2 & 3 are more verbose, and you need to add such code for *every* call to ecore (in a library). So you end up pushing responsibilities to the library writers and applications that are better handled in Ecore itself. IOW, it makes writing ecore code with threads a pain in the butt, and reduces the potential audience of EFL. thanks, Mike ------------------------------------------------------------------------------ Got Input? Slashdot Needs You. Take our quick survey online. Come on, we don't ask for help often. Plus, you'll get a chance to win $100 to spend on ThinkGeek. http://p.sf.net/sfu/slashdot-survey _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel