On Mon, 19 Sep 2016 09:04:15 -0300 Gustavo Sverzut Barbieri
<barbi...@gmail.com> said:

> On Sun, Sep 18, 2016 at 2:03 PM, Carsten Haitzler <ras...@rasterman.com>
> wrote:
> > On Thu, 15 Sep 2016 08:00:46 -0300 Gustavo Sverzut Barbieri
> > <barbi...@gmail.com> said:
> >
> >> isn't it better to check in ecore_thread_cancel() if the thread was
> >> already created?
> >
> > that'd require keeping track of every thread we create, looking up in that
> > list/table ever time etc. ... like eoid does. eina_thread stuff is are ally
> > a tiny tiny tiny thin wrapper over posix (or windows or osx) threading -
> > same with locks/semaphores etc. at this level such a complex check isn't
> > really worth it.
> there is a single place inside ecore_thread_cancel() that calls this
> function and it knows if t->self is 0 before calling.

ummm... you're mixing ecore_thread and eina_thread. different things. :) this
here is about eina_thread which has no t->self. t (thread) *IS* pthread_t. it's
opaque. well it hapens to be pthread_t but we could change it and alloc a
struct in future as long as abi remains the same.

so how do we check if t (Eina_Thread) has been created. basically we'd need to

if (eina_list_find(all_eina_threads, t))
  return pthread_cancel((pthread_t)t) == 0;
return EINA_FALSE;

that means a list walk every time to go find the handle. every
eina_thread_create() has to:

all_eina_threads = eina_list_append(all_eina_threads, t);

We could use a hash. an array. point is we don't track all threads. we'd  have
to start tracking them and to do a check would be a lookup like above.

------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    ras...@rasterman.com

enlightenment-devel mailing list

Reply via email to