On Fri, Jul 29, 2011 at 3:44 AM, Mike McCormack <mj.mccorm...@samsung.com> wrote: > 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.
After re-reading that thread, I think you misunderstood one part of this function. If I added it, it's for you to use it to implement your thread safe idea, as it will provide you the easiest way and a gloal infra to solve the awakening of the main loop. And it also prove that we don't need much lock in the main loop at all to make it thread safe. -- Cedric BAIL ------------------------------------------------------------------------------ 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