summaryrefslogtreecommitdiff
path: root/src/lib/ecore
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-31 16:14:40 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-31 16:14:40 +0000
commit4668d04f0493b26a4cce4d307a9ed1277553c082 (patch)
tree854c9af550983aafa5c8ae2f6030911940120ab8 /src/lib/ecore
parent12e06024520c4d783380ceb0e6ec5d8e40dab6ae (diff)
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
Diffstat (limited to 'src/lib/ecore')
-rw-r--r--src/lib/ecore/ecore_thread.c217
1 files changed, 12 insertions, 205 deletions
diff --git a/src/lib/ecore/ecore_thread.c b/src/lib/ecore/ecore_thread.c
index 4937ef5290..954d3a1827 100644
--- a/src/lib/ecore/ecore_thread.c
+++ b/src/lib/ecore/ecore_thread.c
@@ -18,8 +18,6 @@
18#include "Ecore.h" 18#include "Ecore.h"
19#include "ecore_private.h" 19#include "ecore_private.h"
20 20
21#ifdef EFL_HAVE_THREADS
22
23# define LK(x) Eina_Lock x 21# define LK(x) Eina_Lock x
24# define LKI(x) eina_lock_new(&(x)) 22# define LKI(x) eina_lock_new(&(x))
25# define LKD(x) eina_lock_free(&(x)) 23# define LKD(x) eina_lock_free(&(x))
@@ -45,26 +43,6 @@
45# define PHC(x, f, d) eina_thread_create(&(x), EINA_THREAD_BACKGROUND, -1, (void *)f, d) 43# define PHC(x, f, d) eina_thread_create(&(x), EINA_THREAD_BACKGROUND, -1, (void *)f, d)
46# define PHJ(x) eina_thread_join(x) 44# define PHJ(x) eina_thread_join(x)
47 45
48# ifdef EFL_HAVE_POSIX_THREADS
49# include <pthread.h>
50# ifdef __linux__
51# include <sched.h>
52# include <sys/resource.h>
53# include <unistd.h>
54# include <sys/syscall.h>
55# include <errno.h>
56# endif
57
58# else /* EFL_HAVE_WIN32_THREADS */
59
60# define WIN32_LEAN_AND_MEAN
61# include <windows.h>
62# undef WIN32_LEAN_AND_MEAN
63
64# endif
65
66#endif
67
68typedef struct _Ecore_Pthread_Worker Ecore_Pthread_Worker; 46typedef struct _Ecore_Pthread_Worker Ecore_Pthread_Worker;
69typedef struct _Ecore_Pthread Ecore_Pthread; 47typedef struct _Ecore_Pthread Ecore_Pthread;
70typedef struct _Ecore_Thread_Data Ecore_Thread_Data; 48typedef struct _Ecore_Thread_Data Ecore_Thread_Data;
@@ -108,20 +86,16 @@ struct _Ecore_Pthread_Worker
108 86
109 Ecore_Thread_Cb func_cancel; 87 Ecore_Thread_Cb func_cancel;
110 Ecore_Thread_Cb func_end; 88 Ecore_Thread_Cb func_end;
111#ifdef EFL_HAVE_THREADS
112 PH(self); 89 PH(self);
113 Eina_Hash *hash; 90 Eina_Hash *hash;
114 CD(cond); 91 CD(cond);
115 LK(mutex); 92 LK(mutex);
116#endif
117 93
118 const void *data; 94 const void *data;
119 95
120 int cancel; 96 int cancel;
121 97
122#ifdef EFL_HAVE_THREADS
123 LK(cancel_mutex); 98 LK(cancel_mutex);
124#endif
125 99
126 Eina_Bool message_run : 1; 100 Eina_Bool message_run : 1;
127 Eina_Bool feedback_run : 1; 101 Eina_Bool feedback_run : 1;
@@ -130,7 +104,6 @@ struct _Ecore_Pthread_Worker
130 Eina_Bool no_queue : 1; 104 Eina_Bool no_queue : 1;
131}; 105};
132 106
133#ifdef EFL_HAVE_THREADS
134typedef struct _Ecore_Pthread_Notify Ecore_Pthread_Notify; 107typedef struct _Ecore_Pthread_Notify Ecore_Pthread_Notify;
135struct _Ecore_Pthread_Notify 108struct _Ecore_Pthread_Notify
136{ 109{
@@ -156,12 +129,8 @@ struct _Ecore_Pthread_Message
156 Eina_Bool sync : 1; 129 Eina_Bool sync : 1;
157}; 130};
158 131
159#endif
160
161static int _ecore_thread_count_max = 0; 132static int _ecore_thread_count_max = 0;
162 133
163#ifdef EFL_HAVE_THREADS
164
165static void _ecore_thread_handler(void *data); 134static void _ecore_thread_handler(void *data);
166 135
167static int _ecore_thread_count = 0; 136static int _ecore_thread_count = 0;
@@ -498,12 +467,9 @@ restart:
498 return NULL; 467 return NULL;
499} 468}
500 469
501#endif
502
503static Ecore_Pthread_Worker * 470static Ecore_Pthread_Worker *
504_ecore_thread_worker_new(void) 471_ecore_thread_worker_new(void)
505{ 472{
506#ifdef EFL_HAVE_THREADS
507 Ecore_Pthread_Worker *result; 473 Ecore_Pthread_Worker *result;
508 474
509 result = eina_trash_pop(&_ecore_thread_worker_trash); 475 result = eina_trash_pop(&_ecore_thread_worker_trash);
@@ -519,9 +485,6 @@ _ecore_thread_worker_new(void)
519 CDI(result->cond, result->mutex); 485 CDI(result->cond, result->mutex);
520 486
521 return result; 487 return result;
522#else
523 return malloc(sizeof (Ecore_Pthread_Worker));
524#endif
525} 488}
526 489
527void 490void
@@ -531,20 +494,17 @@ _ecore_thread_init(void)
531 if (_ecore_thread_count_max <= 0) 494 if (_ecore_thread_count_max <= 0)
532 _ecore_thread_count_max = 1; 495 _ecore_thread_count_max = 1;
533 496
534#ifdef EFL_HAVE_THREADS
535 LKI(_ecore_pending_job_threads_mutex); 497 LKI(_ecore_pending_job_threads_mutex);
536 LRWKI(_ecore_thread_global_hash_lock); 498 LRWKI(_ecore_thread_global_hash_lock);
537 LKI(_ecore_thread_global_hash_mutex); 499 LKI(_ecore_thread_global_hash_mutex);
538 LKI(_ecore_running_job_mutex); 500 LKI(_ecore_running_job_mutex);
539 CDI(_ecore_thread_global_hash_cond, _ecore_thread_global_hash_mutex); 501 CDI(_ecore_thread_global_hash_cond, _ecore_thread_global_hash_mutex);
540#endif
541} 502}
542 503
543void 504void
544_ecore_thread_shutdown(void) 505_ecore_thread_shutdown(void)
545{ 506{
546 /* FIXME: If function are still running in the background, should we kill them ? */ 507 /* FIXME: If function are still running in the background, should we kill them ? */
547#ifdef EFL_HAVE_THREADS
548 Ecore_Pthread_Worker *work; 508 Ecore_Pthread_Worker *work;
549 Eina_List *l; 509 Eina_List *l;
550 Eina_Bool test; 510 Eina_Bool test;
@@ -610,7 +570,6 @@ _ecore_thread_shutdown(void)
610 LKD(_ecore_thread_global_hash_mutex); 570 LKD(_ecore_thread_global_hash_mutex);
611 LKD(_ecore_running_job_mutex); 571 LKD(_ecore_running_job_mutex);
612 CDD(_ecore_thread_global_hash_cond); 572 CDD(_ecore_thread_global_hash_cond);
613#endif
614} 573}
615 574
616EAPI Ecore_Thread * 575EAPI Ecore_Thread *
@@ -621,12 +580,10 @@ ecore_thread_run(Ecore_Thread_Cb func_blocking,
621{ 580{
622 Ecore_Pthread_Worker *work; 581 Ecore_Pthread_Worker *work;
623 Eina_Bool tried = EINA_FALSE; 582 Eina_Bool tried = EINA_FALSE;
624#ifdef EFL_HAVE_THREADS
625 PH(thread); 583 PH(thread);
626#endif
627 584
628 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); 585 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
629 586
630 if (!func_blocking) return NULL; 587 if (!func_blocking) return NULL;
631 588
632 work = _ecore_thread_worker_new(); 589 work = _ecore_thread_worker_new();
@@ -648,7 +605,6 @@ ecore_thread_run(Ecore_Thread_Cb func_blocking,
648 work->no_queue = EINA_FALSE; 605 work->no_queue = EINA_FALSE;
649 work->data = data; 606 work->data = data;
650 607
651#ifdef EFL_HAVE_THREADS
652 work->self = 0; 608 work->self = 0;
653 work->hash = NULL; 609 work->hash = NULL;
654 610
@@ -697,33 +653,11 @@ ecore_thread_run(Ecore_Thread_Cb func_blocking,
697 eina_threads_shutdown(); 653 eina_threads_shutdown();
698 654
699 return (Ecore_Thread *)work; 655 return (Ecore_Thread *)work;
700#else
701 /*
702 If no thread and as we don't want to break app that rely on this
703 facility, we will lock the interface until we are done.
704 */
705 do {
706 /* Handle reschedule by forcing it here. That would mean locking the app,
707 * would be better with an idler, but really to complex for a case where
708 * thread should really exist.
709 */
710 work->reschedule = EINA_FALSE;
711
712 func_blocking((void *)data, (Ecore_Thread *)work);
713 if (work->cancel == EINA_FALSE) func_end((void *)data, (Ecore_Thread *)work);
714 else func_cancel((void *)data, (Ecore_Thread *)work);
715 } while (work->reschedule == EINA_TRUE);
716
717 free(work);
718
719 return NULL;
720#endif
721} 656}
722 657
723EAPI Eina_Bool 658EAPI Eina_Bool
724ecore_thread_cancel(Ecore_Thread *thread) 659ecore_thread_cancel(Ecore_Thread *thread)
725{ 660{
726#ifdef EFL_HAVE_THREADS
727 Ecore_Pthread_Worker *volatile work = (Ecore_Pthread_Worker *)thread; 661 Ecore_Pthread_Worker *volatile work = (Ecore_Pthread_Worker *)thread;
728 Eina_List *l; 662 Eina_List *l;
729 int cancel; 663 int cancel;
@@ -794,10 +728,6 @@ ecore_thread_cancel(Ecore_Thread *thread)
794 LKU(work->cancel_mutex); 728 LKU(work->cancel_mutex);
795 729
796 return EINA_FALSE; 730 return EINA_FALSE;
797#else
798 (void) thread;
799 return EINA_TRUE;
800#endif
801} 731}
802 732
803EAPI Eina_Bool 733EAPI Eina_Bool
@@ -807,18 +737,15 @@ ecore_thread_check(Ecore_Thread *thread)
807 int cancel; 737 int cancel;
808 738
809 if (!worker) return EINA_TRUE; 739 if (!worker) return EINA_TRUE;
810#ifdef EFL_HAVE_THREADS
811 LKL(worker->cancel_mutex); 740 LKL(worker->cancel_mutex);
812#endif 741
813 cancel = worker->cancel; 742 cancel = worker->cancel;
814 /* FIXME: there is an insane bug driving me nuts here. I don't know if 743 /* FIXME: there is an insane bug driving me nuts here. I don't know if
815 it's a race condition, some cache issue or some alien attack on our software. 744 it's a race condition, some cache issue or some alien attack on our software.
816 But ecore_thread_check will only work correctly with a printf, all the volatile, 745 But ecore_thread_check will only work correctly with a printf, all the volatile,
817 lock and even usleep don't help here... */ 746 lock and even usleep don't help here... */
818 /* fprintf(stderr, "wc: %i\n", cancel); */ 747 /* fprintf(stderr, "wc: %i\n", cancel); */
819#ifdef EFL_HAVE_THREADS
820 LKU(worker->cancel_mutex); 748 LKU(worker->cancel_mutex);
821#endif
822 return cancel; 749 return cancel;
823} 750}
824 751
@@ -830,13 +757,12 @@ ecore_thread_feedback_run(Ecore_Thread_Cb func_heavy,
830 const void *data, 757 const void *data,
831 Eina_Bool try_no_queue) 758 Eina_Bool try_no_queue)
832{ 759{
833#ifdef EFL_HAVE_THREADS
834 Ecore_Pthread_Worker *worker; 760 Ecore_Pthread_Worker *worker;
835 Eina_Bool tried = EINA_FALSE; 761 Eina_Bool tried = EINA_FALSE;
836 PH(thread); 762 PH(thread);
837 763
838 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); 764 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
839 765
840 if (!func_heavy) return NULL; 766 if (!func_heavy) return NULL;
841 767
842 worker = _ecore_thread_worker_new(); 768 worker = _ecore_thread_worker_new();
@@ -942,38 +868,6 @@ on_error:
942 LKU(_ecore_pending_job_threads_mutex); 868 LKU(_ecore_pending_job_threads_mutex);
943 869
944 return (Ecore_Thread *)worker; 870 return (Ecore_Thread *)worker;
945#else
946 Ecore_Pthread_Worker worker;
947
948 (void)try_no_queue;
949
950 /*
951 If no thread and as we don't want to break app that rely on this
952 facility, we will lock the interface until we are done.
953 */
954 worker.u.feedback_run.func_heavy = func_heavy;
955 worker.u.feedback_run.func_notify = func_notify;
956 worker.u.feedback_run.send = 0;
957 worker.u.feedback_run.received = 0;
958 worker.func_cancel = func_cancel;
959 worker.func_end = func_end;
960 worker.data = data;
961 worker.cancel = EINA_FALSE;
962 worker.feedback_run = EINA_TRUE;
963 worker.message_run = EINA_FALSE;
964 worker.kill = EINA_FALSE;
965
966 do {
967 worker.reschedule = EINA_FALSE;
968
969 func_heavy((void *)data, (Ecore_Thread *)&worker);
970
971 if (worker.cancel) func_cancel((void *)data, (Ecore_Thread *)&worker);
972 else func_end((void *)data, (Ecore_Thread *)&worker);
973 } while (worker.reschedule == EINA_TRUE);
974
975 return NULL;
976#endif
977} 871}
978 872
979EAPI Eina_Bool 873EAPI Eina_Bool
@@ -984,7 +878,6 @@ ecore_thread_feedback(Ecore_Thread *thread,
984 878
985 if (!worker) return EINA_FALSE; 879 if (!worker) return EINA_FALSE;
986 880
987#ifdef EFL_HAVE_THREADS
988 if (!PHE(worker->self, PHS())) return EINA_FALSE; 881 if (!PHE(worker->self, PHS())) return EINA_FALSE;
989 882
990 if (worker->feedback_run) 883 if (worker->feedback_run)
@@ -1027,11 +920,6 @@ ecore_thread_feedback(Ecore_Thread *thread,
1027 return EINA_FALSE; 920 return EINA_FALSE;
1028 921
1029 return EINA_TRUE; 922 return EINA_TRUE;
1030#else
1031 worker->u.feedback_run.func_notify((void *)worker->data, thread, (void *)data);
1032
1033 return EINA_TRUE;
1034#endif
1035} 923}
1036 924
1037#if 0 925#if 0
@@ -1042,7 +930,6 @@ ecore_thread_message_run(Ecore_Thread_Cb func_main,
1042 Ecore_Thread_Cb func_cancel, 930 Ecore_Thread_Cb func_cancel,
1043 const void *data) 931 const void *data)
1044{ 932{
1045#ifdef EFL_HAVE_THREADS
1046 Ecore_Pthread_Worker *worker; 933 Ecore_Pthread_Worker *worker;
1047 PH(t); 934 PH(t);
1048 935
@@ -1087,11 +974,6 @@ ecore_thread_message_run(Ecore_Thread_Cb func_main,
1087 974
1088 CDD(worker->cond); 975 CDD(worker->cond);
1089 LKD(worker->mutex); 976 LKD(worker->mutex);
1090#else
1091 /* Note: This type of thread can't and never will work without thread support */
1092 WRN("ecore_thread_message_run called, but threads disable in Ecore, things will go wrong. Starting now !");
1093# warning "You disabled threads support in ecore, I hope you know what you are doing !"
1094#endif
1095 977
1096 func_cancel((void *) data, NULL); 978 func_cancel((void *) data, NULL);
1097 979
@@ -1106,9 +988,7 @@ ecore_thread_reschedule(Ecore_Thread *thread)
1106 988
1107 if (!worker) return EINA_FALSE; 989 if (!worker) return EINA_FALSE;
1108 990
1109#ifdef EFL_HAVE_THREADS
1110 if (!PHE(worker->self, PHS())) return EINA_FALSE; 991 if (!PHE(worker->self, PHS())) return EINA_FALSE;
1111#endif
1112 992
1113 worker->reschedule = EINA_TRUE; 993 worker->reschedule = EINA_TRUE;
1114 return EINA_TRUE; 994 return EINA_TRUE;
@@ -1117,18 +997,13 @@ ecore_thread_reschedule(Ecore_Thread *thread)
1117EAPI int 997EAPI int
1118ecore_thread_active_get(void) 998ecore_thread_active_get(void)
1119{ 999{
1120#ifdef EFL_HAVE_THREADS
1121 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0); 1000 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0);
1122 return _ecore_thread_count; 1001 return _ecore_thread_count;
1123#else
1124 return 0;
1125#endif
1126} 1002}
1127 1003
1128EAPI int 1004EAPI int
1129ecore_thread_pending_get(void) 1005ecore_thread_pending_get(void)
1130{ 1006{
1131#ifdef EFL_HAVE_THREADS
1132 int ret; 1007 int ret;
1133 1008
1134 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0); 1009 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0);
@@ -1136,15 +1011,11 @@ ecore_thread_pending_get(void)
1136 ret = eina_list_count(_ecore_pending_job_threads); 1011 ret = eina_list_count(_ecore_pending_job_threads);
1137 LKU(_ecore_pending_job_threads_mutex); 1012 LKU(_ecore_pending_job_threads_mutex);
1138 return ret; 1013 return ret;
1139#else
1140 return 0;
1141#endif
1142} 1014}
1143 1015
1144EAPI int 1016EAPI int
1145ecore_thread_pending_feedback_get(void) 1017ecore_thread_pending_feedback_get(void)
1146{ 1018{
1147#ifdef EFL_HAVE_THREADS
1148 int ret; 1019 int ret;
1149 1020
1150 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0); 1021 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0);
@@ -1152,15 +1023,11 @@ ecore_thread_pending_feedback_get(void)
1152 ret = eina_list_count(_ecore_pending_job_threads_feedback); 1023 ret = eina_list_count(_ecore_pending_job_threads_feedback);
1153 LKU(_ecore_pending_job_threads_mutex); 1024 LKU(_ecore_pending_job_threads_mutex);
1154 return ret; 1025 return ret;
1155#else
1156 return 0;
1157#endif
1158} 1026}
1159 1027
1160EAPI int 1028EAPI int
1161ecore_thread_pending_total_get(void) 1029ecore_thread_pending_total_get(void)
1162{ 1030{
1163#ifdef EFL_HAVE_THREADS
1164 int ret; 1031 int ret;
1165 1032
1166 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0); 1033 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0);
@@ -1168,9 +1035,6 @@ ecore_thread_pending_total_get(void)
1168 ret = eina_list_count(_ecore_pending_job_threads) + eina_list_count(_ecore_pending_job_threads_feedback); 1035 ret = eina_list_count(_ecore_pending_job_threads) + eina_list_count(_ecore_pending_job_threads_feedback);
1169 LKU(_ecore_pending_job_threads_mutex); 1036 LKU(_ecore_pending_job_threads_mutex);
1170 return ret; 1037 return ret;
1171#else
1172 return 0;
1173#endif
1174} 1038}
1175 1039
1176EAPI int 1040EAPI int
@@ -1201,16 +1065,12 @@ ecore_thread_max_reset(void)
1201EAPI int 1065EAPI int
1202ecore_thread_available_get(void) 1066ecore_thread_available_get(void)
1203{ 1067{
1204#ifdef EFL_HAVE_THREADS
1205 int ret; 1068 int ret;
1206 1069
1207 LKL(_ecore_pending_job_threads_mutex); 1070 LKL(_ecore_pending_job_threads_mutex);
1208 ret = _ecore_thread_count_max - _ecore_thread_count; 1071 ret = _ecore_thread_count_max - _ecore_thread_count;
1209 LKU(_ecore_pending_job_threads_mutex); 1072 LKU(_ecore_pending_job_threads_mutex);
1210 return ret; 1073 return ret;
1211#else
1212 return 0;
1213#endif
1214} 1074}
1215 1075
1216EAPI Eina_Bool 1076EAPI Eina_Bool
@@ -1220,15 +1080,13 @@ ecore_thread_local_data_add(Ecore_Thread *thread,
1220 Eina_Free_Cb cb, 1080 Eina_Free_Cb cb,
1221 Eina_Bool direct) 1081 Eina_Bool direct)
1222{ 1082{
1223#ifdef EFL_HAVE_THREADS
1224 Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *)thread; 1083 Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *)thread;
1225 Ecore_Thread_Data *d; 1084 Ecore_Thread_Data *d;
1226 Eina_Bool ret; 1085 Eina_Bool ret;
1227#endif
1228 1086
1229 if ((!thread) || (!key) || (!value)) 1087 if ((!thread) || (!key) || (!value))
1230 return EINA_FALSE; 1088 return EINA_FALSE;
1231#ifdef EFL_HAVE_THREADS 1089
1232 if (!PHE(worker->self, PHS())) return EINA_FALSE; 1090 if (!PHE(worker->self, PHS())) return EINA_FALSE;
1233 1091
1234 if (!worker->hash) 1092 if (!worker->hash)
@@ -1249,11 +1107,6 @@ ecore_thread_local_data_add(Ecore_Thread *thread,
1249 ret = eina_hash_add(worker->hash, key, d); 1107 ret = eina_hash_add(worker->hash, key, d);
1250 CDB(worker->cond); 1108 CDB(worker->cond);
1251 return ret; 1109 return ret;
1252#else
1253 (void) cb;
1254 (void) direct;
1255 return EINA_FALSE;
1256#endif
1257} 1110}
1258 1111
1259EAPI void * 1112EAPI void *
@@ -1262,15 +1115,13 @@ ecore_thread_local_data_set(Ecore_Thread *thread,
1262 void *value, 1115 void *value,
1263 Eina_Free_Cb cb) 1116 Eina_Free_Cb cb)
1264{ 1117{
1265#ifdef EFL_HAVE_THREADS
1266 Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *)thread; 1118 Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *)thread;
1267 Ecore_Thread_Data *d, *r; 1119 Ecore_Thread_Data *d, *r;
1268 void *ret; 1120 void *ret;
1269#endif
1270 1121
1271 if ((!thread) || (!key) || (!value)) 1122 if ((!thread) || (!key) || (!value))
1272 return NULL; 1123 return NULL;
1273#ifdef EFL_HAVE_THREADS 1124
1274 if (!PHE(worker->self, PHS())) return NULL; 1125 if (!PHE(worker->self, PHS())) return NULL;
1275 1126
1276 if (!worker->hash) 1127 if (!worker->hash)
@@ -1290,24 +1141,18 @@ ecore_thread_local_data_set(Ecore_Thread *thread,
1290 ret = r->data; 1141 ret = r->data;
1291 free(r); 1142 free(r);
1292 return ret; 1143 return ret;
1293#else
1294 (void) cb;
1295 return NULL;
1296#endif
1297} 1144}
1298 1145
1299EAPI void * 1146EAPI void *
1300ecore_thread_local_data_find(Ecore_Thread *thread, 1147ecore_thread_local_data_find(Ecore_Thread *thread,
1301 const char *key) 1148 const char *key)
1302{ 1149{
1303#ifdef EFL_HAVE_THREADS
1304 Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *)thread; 1150 Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *)thread;
1305 Ecore_Thread_Data *d; 1151 Ecore_Thread_Data *d;
1306#endif
1307 1152
1308 if ((!thread) || (!key)) 1153 if ((!thread) || (!key))
1309 return NULL; 1154 return NULL;
1310#ifdef EFL_HAVE_THREADS 1155
1311 if (!PHE(worker->self, PHS())) return NULL; 1156 if (!PHE(worker->self, PHS())) return NULL;
1312 1157
1313 if (!worker->hash) 1158 if (!worker->hash)
@@ -1317,30 +1162,22 @@ ecore_thread_local_data_find(Ecore_Thread *thread,
1317 if (d) 1162 if (d)
1318 return d->data; 1163 return d->data;
1319 return NULL; 1164 return NULL;
1320#else
1321 return NULL;
1322#endif
1323} 1165}
1324 1166
1325EAPI Eina_Bool 1167EAPI Eina_Bool
1326ecore_thread_local_data_del(Ecore_Thread *thread, 1168ecore_thread_local_data_del(Ecore_Thread *thread,
1327 const char *key) 1169 const char *key)
1328{ 1170{
1329#ifdef EFL_HAVE_THREADS
1330 Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *)thread; 1171 Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *)thread;
1331#endif
1332 1172
1333 if ((!thread) || (!key)) 1173 if ((!thread) || (!key))
1334 return EINA_FALSE; 1174 return EINA_FALSE;
1335#ifdef EFL_HAVE_THREADS 1175
1336 if (!PHE(worker->self, PHS())) return EINA_FALSE; 1176 if (!PHE(worker->self, PHS())) return EINA_FALSE;
1337 1177
1338 if (!worker->hash) 1178 if (!worker->hash)
1339 return EINA_FALSE; 1179 return EINA_FALSE;
1340 return eina_hash_del_by_key(worker->hash, key); 1180 return eina_hash_del_by_key(worker->hash, key);
1341#else
1342 return EINA_TRUE;
1343#endif
1344} 1181}
1345 1182
1346EAPI Eina_Bool 1183EAPI Eina_Bool
@@ -1349,14 +1186,12 @@ ecore_thread_global_data_add(const char *key,
1349 Eina_Free_Cb cb, 1186 Eina_Free_Cb cb,
1350 Eina_Bool direct) 1187 Eina_Bool direct)
1351{ 1188{
1352#ifdef EFL_HAVE_THREADS
1353 Ecore_Thread_Data *d; 1189 Ecore_Thread_Data *d;
1354 Eina_Bool ret; 1190 Eina_Bool ret;
1355#endif
1356 1191
1357 if ((!key) || (!value)) 1192 if ((!key) || (!value))
1358 return EINA_FALSE; 1193 return EINA_FALSE;
1359#ifdef EFL_HAVE_THREADS 1194
1360 LRWKWL(_ecore_thread_global_hash_lock); 1195 LRWKWL(_ecore_thread_global_hash_lock);
1361 if (!_ecore_thread_global_hash) 1196 if (!_ecore_thread_global_hash)
1362 _ecore_thread_global_hash = eina_hash_string_small_new(_ecore_thread_data_free); 1197 _ecore_thread_global_hash = eina_hash_string_small_new(_ecore_thread_data_free);
@@ -1378,11 +1213,6 @@ ecore_thread_global_data_add(const char *key,
1378 LRWKU(_ecore_thread_global_hash_lock); 1213 LRWKU(_ecore_thread_global_hash_lock);
1379 CDB(_ecore_thread_global_hash_cond); 1214 CDB(_ecore_thread_global_hash_cond);
1380 return ret; 1215 return ret;
1381#else
1382 (void) cb;
1383 (void) direct;
1384 return EINA_TRUE;
1385#endif
1386} 1216}
1387 1217
1388EAPI void * 1218EAPI void *
@@ -1390,14 +1220,12 @@ ecore_thread_global_data_set(const char *key,
1390 void *value, 1220 void *value,
1391 Eina_Free_Cb cb) 1221 Eina_Free_Cb cb)
1392{ 1222{
1393#ifdef EFL_HAVE_THREADS
1394 Ecore_Thread_Data *d, *r; 1223 Ecore_Thread_Data *d, *r;
1395 void *ret; 1224 void *ret;
1396#endif
1397 1225
1398 if ((!key) || (!value)) 1226 if ((!key) || (!value))
1399 return NULL; 1227 return NULL;
1400#ifdef EFL_HAVE_THREADS 1228
1401 LRWKWL(_ecore_thread_global_hash_lock); 1229 LRWKWL(_ecore_thread_global_hash_lock);
1402 if (!_ecore_thread_global_hash) 1230 if (!_ecore_thread_global_hash)
1403 _ecore_thread_global_hash = eina_hash_string_small_new(_ecore_thread_data_free); 1231 _ecore_thread_global_hash = eina_hash_string_small_new(_ecore_thread_data_free);
@@ -1420,22 +1248,16 @@ ecore_thread_global_data_set(const char *key,
1420 ret = r->data; 1248 ret = r->data;
1421 free(r); 1249 free(r);
1422 return ret; 1250 return ret;
1423#else
1424 (void) cb;
1425 return NULL;
1426#endif
1427} 1251}
1428 1252
1429EAPI void * 1253EAPI void *
1430ecore_thread_global_data_find(const char *key) 1254ecore_thread_global_data_find(const char *key)
1431{ 1255{
1432#ifdef EFL_HAVE_THREADS
1433 Ecore_Thread_Data *ret; 1256 Ecore_Thread_Data *ret;
1434#endif
1435 1257
1436 if (!key) 1258 if (!key)
1437 return NULL; 1259 return NULL;
1438#ifdef EFL_HAVE_THREADS 1260
1439 if (!_ecore_thread_global_hash) return NULL; 1261 if (!_ecore_thread_global_hash) return NULL;
1440 1262
1441 LRWKRL(_ecore_thread_global_hash_lock); 1263 LRWKRL(_ecore_thread_global_hash_lock);
@@ -1444,21 +1266,16 @@ ecore_thread_global_data_find(const char *key)
1444 if (ret) 1266 if (ret)
1445 return ret->data; 1267 return ret->data;
1446 return NULL; 1268 return NULL;
1447#else
1448 return NULL;
1449#endif
1450} 1269}
1451 1270
1452EAPI Eina_Bool 1271EAPI Eina_Bool
1453ecore_thread_global_data_del(const char *key) 1272ecore_thread_global_data_del(const char *key)
1454{ 1273{
1455#ifdef EFL_HAVE_THREADS
1456 Eina_Bool ret; 1274 Eina_Bool ret;
1457#endif
1458 1275
1459 if (!key) 1276 if (!key)
1460 return EINA_FALSE; 1277 return EINA_FALSE;
1461#ifdef EFL_HAVE_THREADS 1278
1462 if (!_ecore_thread_global_hash) 1279 if (!_ecore_thread_global_hash)
1463 return EINA_FALSE; 1280 return EINA_FALSE;
1464 1281
@@ -1466,23 +1283,18 @@ ecore_thread_global_data_del(const char *key)
1466 ret = eina_hash_del_by_key(_ecore_thread_global_hash, key); 1283 ret = eina_hash_del_by_key(_ecore_thread_global_hash, key);
1467 LRWKU(_ecore_thread_global_hash_lock); 1284 LRWKU(_ecore_thread_global_hash_lock);
1468 return ret; 1285 return ret;
1469#else
1470 return EINA_TRUE;
1471#endif
1472} 1286}
1473 1287
1474EAPI void * 1288EAPI void *
1475ecore_thread_global_data_wait(const char *key, 1289ecore_thread_global_data_wait(const char *key,
1476 double seconds) 1290 double seconds)
1477{ 1291{
1478#ifdef EFL_HAVE_THREADS
1479 double tm = 0; 1292 double tm = 0;
1480 Ecore_Thread_Data *ret = NULL; 1293 Ecore_Thread_Data *ret = NULL;
1481#endif
1482 1294
1483 if (!key) 1295 if (!key)
1484 return NULL; 1296 return NULL;
1485#ifdef EFL_HAVE_THREADS 1297
1486 if (!_ecore_thread_global_hash) 1298 if (!_ecore_thread_global_hash)
1487 return NULL; 1299 return NULL;
1488 if (seconds > 0) 1300 if (seconds > 0)
@@ -1501,9 +1313,4 @@ ecore_thread_global_data_wait(const char *key,
1501 } 1313 }
1502 if (ret) return ret->data; 1314 if (ret) return ret->data;
1503 return NULL; 1315 return NULL;
1504#else
1505 (void) seconds;
1506 return NULL;
1507#endif
1508} 1316}
1509