For whatever reason, I didn't receive the first email of this chain, so will 
answer here.

-------- Original Message --------
 On February 27, 2018 7:21 AM, Mike Blumenkrantz 
<[email protected]> wrote:
>You've certainly raised some valid points which bear further looking into,
> thanks!
>
> At a minimum, this patch was intended to introduce a base implementation of
> a singleton "app" object which could (and should) have tests written for it
> as it's improved upon. If you or others want to do that work feel free,
> I've moved on to other items for the near future.
>
> On Tue, Feb 27, 2018 at 12:07 AM Carsten Haitzler [email protected]
>wrote:
>
>>On Mon, 26 Feb 2018 11:03:03 -0800 Mike Blumenkrantz
>>[email protected] said:
>>this change has a fair few problems to it... i don't think this is the
>> right
>> way to go.
>>this change from efl_main_loop_get() doesn't make sense
>> - job = efl_add(EFL_IO_MANAGER_CLASS, efl_main_loop_get());
>>
>> - job = efl_add(EFL_IO_MANAGER_CLASS,
>> efl_app_main_loop_get(efl_app_get()));

I disagree on both of those line. You get the main loop when your application 
start and all your object do get you there. The scenario in which you need to 
directly access the main loop should be really limited (tests and legacy code 
are what come to my mind).

>>you can't access the app object from anywhere other than the main loop
>> thread because it's a thread local object (the default)... so all this
>> does it make this longer for no benefit.

This is the point. Why would you need to access this object from another thread 
?

>> if can't be a shared object either because you also do things like:
>> - EINA_LIST_FOREACH_SAFE(pd->loops, l, ll, loop)
>> - efl_del(loop);
>>
>>you want to have multiple loops in a single thread-local shared object? you
>> can't mix shared and non-share objects. 

There is a lot in this sentence. The fact we can't mix shared and non-shared 
object is going to be a serious problem with our parent model and object 
refcounting in general. Basically we will require to have another tree of 
shared object on the side that is not connected to the one that are not shared. 
And all of this object have to be controlled by the user call to the domain 
API. This is a lot of receipe for error and problems.

>> this wouldn't even be able to delete the other loops belong to threads, and 
>> multiple loops
>> in a single thread just make zero sense.loops are intended to run a thread, 
>> not be multiple
>> of them within a thread. i thought this had been discussed?

It has been and the conclusion was that the new logic that was pushed in tree 
broke the previous one which had the intent to make it work. We concluded it 
was hard to get that working again and not a priority, but not that it should 
not be a scenario for the future as much as I remember. My expectation with 
this code is that only the main loop running in the main thread end up there. 
Overall, this is a details as this new thread model is really not a priority 
for this release as no bindings can use it and legacy API can still be used.

<snip>

>>here is what i have been mulling and i think might be right:
>>an efl.app or efl.mainloop class that INHERITS from efl.loop. i.e.:
>>class Efl.App (Efl.Loop)
>> {
>> ...
>> }
>>so the main loop will be of this efl.app or efl.mainloop class and then
>> other loops in threads will be of the regular efl.loop class, not the efl.app
>> class. no parent + child containing all the loops here and so no cross-thread
>> boundaries are crossed. then the efl.app or efl.mainloop class can have the
>> signal events move to it. the same main loop or app object we had before
>> stays, but it just gets a new class on top.

We did consider that too, but we rulled against it as we think it will likely 
increase maintenance complexity. We can disagree on that, but overall I don't 
see why one would be easier than the other.

>> it's simpler and won't have the above issues (and others i can begin to
>> see/imagining). you know if your loop is the main loop with efl_isa(loop,
>> EFL_APP_CLASS) on it. the efl_main_loop_get() can change to efl_app_get()
>> and be shorter and sweeter, with perhaps later an efl_current_loop_get() that
>> gets the loop for that thread from a TLS that works in threads and in main 
>> loop
>> too once we have api to spawn threads and handle binding them together with
>> comms pipes.

I am not a fan at all of relying on TLS for this things especially when all the 
code will be given a context via at least an object that can lead you back 
directly to a loop or the application.

>> it's simpler than your changes here and has fewer problems. i don't think
>> loops will or should be children like you have above of an object. they have 
>> to
>> be loosely coupled. they need to have just regular structs ptrs inside the
>> loop object to track child threads and how to communicate with them. to
>> delete them you need to co-operatively request their delete e.g. via a 
>> pipe/fd
>> setup to the other end, then the loop at the other end exits automatically 
>> when
>> it gets this event/request on their end of the pipe and deletes itself.
>> listen to the del event on the loop object to handle shutdown of anything
>> pending on that thread if you want to ensure you clean up anything you
>> created on the thread end of things. actually any thread/loop probably has 
>> to wait
>> for "child thread/loops" to exit before exiting itself (should join all the
>> thread's at a minimum). it can hold the exit request pending and keep the
>> loop running until all children have reported back to have exited. this does
>> present one possible exception - the main loop. should it wait too? that is 
>> a good
>> question, but definitely all other threads/loops should wait so we end up
>> with a nice organized tree of threads/loops or ... tasks that have
>> "children" (thread/process thread/task children not object children) finish
>> before the parent does so you have a nice guaranteed cleanliness by
>> default at least.

I think we are getting seriously distracted with all of this threads/loops 
here. As said above, it is unlikely that we can make that part of our API 
stable for next release. It would require change in Eo and Eoliand to make 
binding aware of thread ownership. This would obviously require to make sure 
that language that do have a very different approach to this problematic be 
able to get the information they need to make binding work. With that 
constraint in mind, I am pretty certain we have no time to investigate this 
details for next release and that the only case that matter in the use case for 
one main loop with the goal of a simpler code for us to maintain also.

If you think it is best to have one object Efl.App that inherit from Efl.Loop 
and that it will be easy to maintain. Please go ahead and do it. I have no 
strong opinion on this at all, but please keep in mind that we want to make a 
release rather sooner than later and going down the threads rabbit hole is not 
really something we have time to work on at this point.

Cedric

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to