From: caro Date: Tue, 24 May 2011 06:29:58 +0000 (+0000) Subject: Eina: Implement eina_sched_prio_drop() on Windows X-Git-Tag: 2.0_alpha~70^2~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=44691d0b2163c49c3b2bd2bd3c3bf1bb18e942c5;p=framework%2Fuifw%2Feina.git Eina: Implement eina_sched_prio_drop() on Windows git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@59637 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/ChangeLog b/ChangeLog index ffd57a1..5354a68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -85,3 +85,7 @@ 2011-05-18 Cedric Bail * Fix eina_share_common_init to be called only once. + +2011-05-24 Vincent Torri + + * Implement eina_sched_prio_drop() on Windows diff --git a/src/lib/eina_sched.c b/src/lib/eina_sched.c index 85d04eb..45fcc00 100644 --- a/src/lib/eina_sched.c +++ b/src/lib/eina_sched.c @@ -30,6 +30,14 @@ # endif #endif +#ifdef EFL_HAVE_WIN32_THREADS +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include +# undef WIN32_LEAN_AND_MEAN +#endif + #include "eina_sched.h" #include "eina_log.h" @@ -61,7 +69,7 @@ eina_sched_prio_drop(void) pthread_setschedparam(pthread_id, pol, ¶m); } -#ifdef __linux__ +# ifdef __linux__ else { errno = 0; @@ -75,7 +83,23 @@ eina_sched_prio_drop(void) setpriority(PRIO_PROCESS, 0, prio); } } -#endif +# endif +#elif defined EFL_HAVE_WIN32_THREADS + HANDLE thread; + + thread = OpenThread(THREAD_SET_INFORMATION, + FALSE, + GetCurrentThreadId()); + if (!thread) + { + EINA_LOG_ERR("Can not open current thread"); + return; + } + + if (!SetThreadPriority(thread, THREAD_PRIORITY_BELOW_NORMAL)) + EINA_LOG_ERR("Can not set thread priority"); + + CloseHandle(thread); #else EINA_LOG_ERR("Eina does not have support for threads enabled" "or it doesn't support setting scheduler priorities");