Commit Graph

45 Commits

Author SHA1 Message Date
Felipe Magno de Almeida b0f5c73ea3 ecore: Rename EAPI macro to ECORE_API in Ecore library
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.

EAPI was designed to be able to pass
```__attribute__ ((visibility ("default")))``` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.

MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.

For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.

With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).

Example 1:
dll1:
```
EAPI void foo(void);

EAPI void bar()
{
  foo();
}
```
dll2:
```
EAPI void foo()
{
  printf ("foo\n");
}
```

This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
```__atttribute__((visibility("default")))```.

However, the following:
Example 2:

dll1:

```
EAPI extern int foo;
EAPI void foobar(void);

EAPI void bar()
{
  foo = 5;
  foobar();
}
```

dll2:

```
EAPI int foo = 0;
EAPI void foobar()
{
  printf ("foo %d\n", foo);
}
```

This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.

Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
2020-09-20 10:23:26 -03:00
Carsten Haitzler a555fbf769 ecore thread - feedback threads should not be background threads...
if try_no_queue is used - its a thread that clearly wantt to be out of
the queue to run on its own so probably wants to wake up accurately
and thus not be a backgroun rpriority task but and urgent one. ensure
we set up priority accordingly as we didn't before. this should fix
scheduling when under load for vsync

@fix
2020-05-23 09:34:57 +01:00
Woochanlee 802f414b25 ecore_thread: Fix arguments to match with the function call.
see the _eina_thread_internal() function

r = c->func((void*) c->data, eina_thread_self());

The second param has been missed in ecore_thread_worker, ecore_direct_worker functions.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10073
2019-09-23 10:33:15 -07:00
Vincent Torri 839f22870b bin/efl and ecore: include evil_private.h when appropriate
Test Plan: compilation

Reviewers: raster, zmike, cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8908
2019-05-17 11:53:35 +01:00
Carsten Haitzler f80b8979ba ecore thread - fix warn - callback prototypes to match correct type
we pass void *'s to these cb's not int's or thread handled (whatever
typt they may be). so cast inside func not use wrong type.
2018-11-09 11:43:59 +00:00
Mike Blumenkrantz b455617500 ecore/thread: flush main loop threads during ecore_thread_wait()
this avoids the case where the main loop is waiting on a thread
and that same thread is waiting on the main loop

@fix

Differential Revision: https://phab.enlightenment.org/D6438
2018-06-28 18:08:45 +02:00
Mike Blumenkrantz 04d209e238 ecore/thread: flush main loop threads while waiting during shutdown
if a thread is actively waiting on the main loop in order to proceed
with its exit, a flush here avoids the case where the thread waits
until the main loop has exited

Differential Revision: https://phab.enlightenment.org/D6437
2018-06-28 18:08:45 +02:00
Mike Blumenkrantz 2ee83cc28d ecore/thread: increase loop iterations when waiting during shutdown
since this is now a smaller wait interval, looping more times helps
ensure success for threads which have longer blocking operations
between lifetime checks

Differential Revision: https://phab.enlightenment.org/D6436
2018-06-28 18:08:45 +02:00
Mike Blumenkrantz 6eaa57852a ecore/thread: greatly reduce usleep time during shutdown loop
Summary:
now that ecore accurately waits on all threads while exiting, this
loop needs to run much more frequently in order to avoid waiting for
an unreasonably long time when exiting

Reviewers: ManMower, devilhorns

Reviewed By: ManMower

Subscribers: cedric, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6427
2018-06-25 17:27:18 -04:00
Mike Blumenkrantz 1dc706a3dd ecore/thread: track "no_queue" threads
these threads are still managed by the main loop, meaning they must be
accounted for so that they can be waited on if necessary during shutdown

this resolves some issues where ecore-con threads would persist after the
main thread had exited or called ecore_shutdown

@fix
fix T7041

this is the final version of the patch and not the mangled version which
was previously committed

Differential Revision: https://phab.enlightenment.org/D6354
2018-06-25 16:54:24 -04:00
Mike Blumenkrantz 8d2f5d7a7d Revert "ecore/thread: track "no_queue" threads"
This reverts commit 1e47db6a71.

somehow arc managed to land an old revision of this which was not consistent
with the final version of D6354
2018-06-25 16:53:40 -04:00
Mike Blumenkrantz 1e47db6a71 ecore/thread: track "no_queue" threads
these threads are still managed by the main loop, meaning they must be
accounted for so that they can be waited on if necessary during shutdown

this resolves some issues where ecore-con threads would persist after the
main thread had exited or called ecore_shutdown

@fix
fix T7041

Differential Revision: https://phab.enlightenment.org/D6354
2018-06-25 15:14:31 -04:00
Mike Blumenkrantz 198016d503 ecore: reformat ecore_thread.c
no functional changes

Differential Revision: https://phab.enlightenment.org/D6352
2018-06-25 15:14:30 -04:00
Cedric BAIL cdbbaede7e efl: remove old Efl_Future, Efl_Promise. 2018-05-01 10:39:01 -07:00
Cedric BAIL 894c2e6c8c ecore: remove BETA thread API integration with old Efl_Future. 2018-05-01 10:39:01 -07:00
Carsten Haitzler 1c74aaa7e9 Revert "cxx: Fix manual code after efl_app change."
This reverts commit 135154303b.

Revert "efl: move signal events from efl.loop to efl.app"
This reverts commit 3dbca39f98.

Revert "efl: add test suite for efl_app"
This reverts commit 3e94be5d73.

Revert "efl: create Efl.App class, the parent of Efl.Loop"
This reverts commit 28fe00b94e.

Go back to before efl.app because I think this should be done with
superclassing here not a parent object. reasons?

1. multiple loops per single thread make no sense. so if multilpe loop
objects they wont be contained in a single app object and then deleted
like this.
2. the app object is not really sharable in this design so it cant be
accessed from other threads
3. it makes it harder to get the main loop or app object (well 2 func
calls one calling the other and more typing. it is longer to type and
more work where it is not necessary, and again it can't work from
other threads unless we go duplicating efl.app per thread and then
what is the point of splittyign out the signal events from efl.loop
then?)

etc.
2018-03-03 13:40:33 +09:00
Mike Blumenkrantz 28fe00b94e efl: create Efl.App class, the parent of Efl.Loop 2018-02-26 14:02:51 -05:00
Mike Blumenkrantz 8f2b36b774 ecore: prune existing thread_join callbacks during ecore_fork_reset
permitting these to persist and trigger at a later point will cause
the process to deadlock while attempting to join non-existent threads

@fix
2018-01-25 15:33:25 -05:00
Carsten Haitzler 9bedda14b3 efl loop - rename ecore_main_loop_get to efl_main_loop_get
ecore_main_loop_get() is really a new "eo api" but it's using our old
ecore_* namespace, so move to the new efl namespace.
2018-01-02 16:13:54 +09:00
Cedric Bail ab1080bdd3 ecore: allow other thread to write local data on a thread to increase utility. 2017-09-28 18:31:34 -07:00
Vincent Torri 0cdd501246 EFL For WIN32: Replace HAVE_EVIL define with _WIN32 2017-09-22 05:06:10 -05:00
Umesh Tanwar b313b30cf7 ecore: proper macro usage for double comparision. Summary: The comparisions are done between doubles. EINA_FLT_EQ -> EINA_DBL_EQ
Summary: Signed-off-by: Umesh Tanwar <umesh.tanwar@samsung.com>

Reviewers: singh.amitesh, cedric

Subscribers: jpeg, atulfokk

Differential Revision: https://phab.enlightenment.org/D4719

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-03-21 11:11:23 -07:00
Marcel Hollerbach 097f9cfe5f ecore_thread: do not override the data field of a thread
otherwise a currently executed ecore_thread is going to pass a complete
wrong data to its callbacks.

fix T5175
fix T5173
2017-03-02 20:13:58 +01:00
Carsten Haitzler 51c7c9bc99 ecore thread - up default 3 of thread workers to 4x cpu cures
this ups it from number of cpu cores to 4 times that (so if threads to
blocking i/o the spare cycles can be used up).
2017-02-08 08:48:35 +09:00
Chidambar Zinnoury cece2b53d7 ecore thread: Fix waiting.
Waiting would sometimes return as if the thread finished correctly while it is still running.

 This is because we’re waiting for the waiter data to be null… but this is always the case if the user-passed data is null!

 @fix
2017-02-04 23:44:31 +01:00
Cedric BAIL 8f1c071d6a eina: rename EINA_{FLT,DBL}_CMP to EINA_{FLT,DBL}_EQ. 2017-01-06 15:58:46 -08:00
Marcel Hollerbach f32486ced5 ecore_thread: reset waiter and worker when we have failed
otherwise the func_end and func_cancel can get into a endless recursion.
2016-12-28 12:19:40 +01:00
Marcel Hollerbach 46131ea80c ecore_thread: null out the struct before returning it
it can contain old callback values which are not overwritten in every
case. This just ensures that in both cases, empty trasher or none empty
trasher, are returning the same state of the struct.
2016-12-27 17:55:25 +01:00
Cedric BAIL 667b4340b9 ecore: remove floating point comparison warning from Ecore_Thread code. 2016-12-19 16:33:46 -08:00
Guilherme Iscaro 2d1e7ff927 Ecore_Thread: Avoid compiler warning
Use PRIuPTR to print the Eina_Thread handle.
2016-10-10 14:20:47 -03:00
Cedric BAIL 6c514dddb3 ecore: add a prototype ecore_thread helper with Efl_Promise/Efl_Future coupled. 2016-09-26 16:35:52 -07:00
Gustavo Sverzut Barbieri 960e1a1d16 eina/ecore: allow threads to be canceled, use in ecore_con.
As discussed in the mailing list, many people will use worker threads
to execute blocking syscalls and mandating ecore_thread_check() for
voluntary preemption reduces the ecore_thread usefulness a lot.

A clear example is ecore_con usage of connect() and getaddrinfo() in
threads. If the connect timeout expires, the thread will be cancelled,
but it was blocked on syscalls and they will hang around for long
time. If the application exits, ecore will print an error saying it
can SEGV.

Then enable access to pthread_setcancelstate(PTHREAD_CANCEL_ENABLE)
via eina_thread_cancellable_set(EINA_TRUE), to pthread_cancel() via
eina_thread_cancel(), to pthread_cleanup_push()/pthread_cleanup_pop()
via EINA_THREAD_CLEANUP_PUSH()/EINA_THREAD_CLEANUP_POP() and so on.

Ecore threads will enforce non-cancellable threads on its own code,
but the user may decide to enable that and allow cancellation, that's
not an issue since ecore_thread now plays well and use cleanup
functions.

Ecore con connect/resolve make use of that and enable cancellable
state, efl_net_dialer_tcp benefits a lot from that.

A good comparison of the benefit is to run:

   ./src/examples/ecore/efl_io_copier_example tcp://google.com:1234 :stdout:

before and after. It will timeout after 30s and with this patch the
thread is gone, no ecore error is printed about possible SEGV.
2016-09-14 01:47:23 -03:00
Shinwoo Kim 163b50d0f1 ecore: thread - need to null check of function pointer
Summary: you can meet a segmentation fault without this patch

Test Plan:
please use the following snippet
   Ecore_Thread  *th;
   th = ecore_thread_feedback_run(_heavy_cb, _notify_cb, NULL, NULL, obj, EINA_TRUE);
   ecore_thread_wait(th, 1.0);

Reviewers: raster, Hermet, jaehwan, woohyun, cedric

Reviewed By: cedric

Subscribers: seoz

Differential Revision: https://phab.enlightenment.org/D3315

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-11-10 14:10:02 -08:00
Cedric BAIL c4117cdae4 ecore: fix usage eina_condition_timedwait to use relative time instead of absolute time.
This could lead to some very long and unexpected pause as the timeout passed
to eina_condition_timedwait was passed as a absolute time instead of relative.
Hopefully we don't build rocket.
2015-10-14 11:03:21 -07:00
Carsten Haitzler 5b2baf173e efl - set thread names for internally created threads for debugging
@feature
2015-09-10 15:17:08 +09:00
Jérémy Zurcher cb670931d6 ecore: fix compilation, missing return value in ecore_thread_wait
@fix ecore_thread_wait return EINA_TRUE if execution is over or thread is NULL
2015-01-07 22:12:29 +01:00
Cedric BAIL e5ddfb4b2b ecore: add ecore_thread_wait and necessary infrastructure.
This enable the possibility to block the main loop until a
specific thread is done. It may trigger still process ending
of other thread during that function call, but not any other
type of event (timer, animator, idler, ... are all ignored).
2015-01-07 16:45:07 +01:00
Carsten Haitzler ddc09dd04e fix ecore_thread_global_data_wait to work when no data exists yet
@fix

this is based on feedback from wonil choi, where this didn't work
right. this also has an if check for the hash itself.
2014-05-15 21:23:51 +09:00
Cedric Bail 7caef271dc ecore: Use Eina_Spinlock for Ecore_Thread. 2013-10-11 11:08:17 +09:00
Mariusz Grzegorczyk ec67ea9c1e ecore: fix segfault while adding new local or global data to thread. 2013-09-03 12:44:27 +09:00
Chris Michael 18a9719003 Fix memleak of Ecore_Thread_Data reported by Coverity
NB: Fixes Coverity CID1039280

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2013-07-08 12:54:42 +01:00
Cedric Bail 8dedcfae2c Fix warnings 2013-03-11 10:34:47 +09:00
Lucas De Marchi db395ef7eb efl: Remove check for unistd.h
* unistd.h: is very useful, very old and very standard.



SVN revision: 82577
2013-01-10 20:25:26 +00:00
Gustavo Sverzut Barbieri 4668d04f04 efl: cleanup HAVE_THREADS and pthread usage outside of eina.
Eina now abstracts threads, so use that.

the touched files had the EFL_HAVE_THREADS as it's mandatory now.



SVN revision: 81935
2012-12-31 16:14:40 +00:00
Vincent Torri 7d6010b12c merge: add escape ecore, fix several bugs
SVN revision: 79995
2012-12-02 22:35:45 +00:00