aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-10-25 05:21:58 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-10-25 05:21:58 +0000
commite082ab0e741c49fd8fee11be94f460a001befa9e (patch)
treec0fad1b4b356ddfd3bd1bddcaf6456d33de8a6f5
parent2de9c7a47bab8e3e8743c62f72c5091ad92330d6 (diff)
downloadefl-e082ab0e741c49fd8fee11be94f460a001befa9e.tar.gz
efl-e082ab0e741c49fd8fee11be94f460a001befa9e.tar.xz
efl-e082ab0e741c49fd8fee11be94f460a001befa9e.zip
Eina: add affinity to win32 code.
It's not working yet: * eina_thread.c:152:33: error: 'index' undeclared (first use in this function) * eina_thread.c:295:4: warning: passing argument 3 of '_eina_thread_win32_create' from incompatible pointer type [enabled by default] also: * line 142, is it normal that we call eina_list_append() with tw being NULL ? * is what I did in the close_thread label correct ? SVN revision: 78416
-rw-r--r--m4/efl_threads.m41
-rw-r--r--src/lib/eina/eina_thread.c20
2 files changed, 14 insertions, 7 deletions
diff --git a/m4/efl_threads.m4 b/m4/efl_threads.m4
index a1bcc0308..bba617f95 100644
--- a/m4/efl_threads.m4
+++ b/m4/efl_threads.m4
@@ -24,6 +24,7 @@ _efl_have_win32_threads="no"
case "$host_os" in
mingw*)
_efl_have_win32_threads="yes"
+ efl_have_setaffinity="yes"
AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
;;
diff --git a/src/lib/eina/eina_thread.c b/src/lib/eina/eina_thread.c
index 993b47912..401568121 100644
--- a/src/lib/eina/eina_thread.c
+++ b/src/lib/eina/eina_thread.c
@@ -22,10 +22,6 @@
#include <stdlib.h>
-#ifdef HAVE_EVIL
-# include <Evil.h>
-#endif
-
#include "eina_config.h"
#include "eina_thread.h"
#include "eina_sched.h"
@@ -35,6 +31,8 @@
# elif defined(_WIN32)
+# include "eina_list.h"
+
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN
@@ -72,6 +70,8 @@ static Eina_Thread
_eina_thread_win32_self(void)
{
HANDLE t;
+ Eina_Thread_Win32 *tw;
+ Eina_List *l;
t = GetCurrentThread();
EINA_LIST_FOREACH(_thread_running, l, tw)
@@ -121,20 +121,26 @@ _eina_thread_win32_create(Eina_Thread *t,
} while (tw->index == 0); /* prevent having a "false" main loop */
}
- tw->func = f;
- tw->data = d;
+ tw->func = func;
+ tw->data = (void *)data;
tw->thread = CreateThread(NULL, 0, _eina_thread_win32_cb, tw, 0, NULL);
if (!tw->thread) goto on_error;
+ if (!SetThreadAffinityMask(tw->thread, 1 << affinity))
+ goto close_thread;
+
_thread_running = eina_list_append(_thread_running, tw);
*t = tw->index;
return EINA_TRUE;
+ close_thread:
+ Closehandle(tw->thread);
+ tw->thread = NULL;
on_error:
_thread_pool = eina_list_append(_thread_pool, tw);
- return EINA_FALSE;
+ return EINA_FALSE;
}
static void *