diff --git a/legacy/ecore/src/lib/ecore/Ecore.h b/legacy/ecore/src/lib/ecore/Ecore.h index b79a9cd098..0a537cc410 100644 --- a/legacy/ecore/src/lib/ecore/Ecore.h +++ b/legacy/ecore/src/lib/ecore/Ecore.h @@ -77,6 +77,8 @@ extern "C" { #define ECORE_EVENT_SIGNAL_REALTIME 5 /**< Realtime signal event */ #define ECORE_EVENT_COUNT 6 +#define ECORE_EXE_PRIORITY_INHERIT 9999 + EAPI extern int ECORE_EXE_EVENT_ADD; /**< A child process has been added */ EAPI extern int ECORE_EXE_EVENT_DEL; /**< A child process has been deleted (it exited, naming consistant with the rest of ecore). */ EAPI extern int ECORE_EXE_EVENT_DATA; /**< Data from a child process. */ @@ -237,6 +239,8 @@ extern "C" { #ifndef _WIN32 + EAPI void ecore_exe_run_priority_set(int pri); + EAPI int ecore_exe_run_priority_get(void); EAPI Ecore_Exe *ecore_exe_run(const char *exe_cmd, const void *data); EAPI Ecore_Exe *ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data); EAPI int ecore_exe_send(Ecore_Exe *exe, void *data, int size); @@ -281,7 +285,8 @@ extern "C" { EAPI void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags); EAPI double ecore_time_get(void); - + EAPI double ecore_loop_time_get(void); + EAPI Ecore_Timer *ecore_timer_add(double in, int (*func) (void *data), const void *data); EAPI void *ecore_timer_del(Ecore_Timer *timer); EAPI void ecore_timer_interval_set(Ecore_Timer *timer, double in); diff --git a/legacy/ecore/src/lib/ecore/ecore_exe.c b/legacy/ecore/src/lib/ecore/ecore_exe.c index ed32bcedf9..19e70343e6 100644 --- a/legacy/ecore/src/lib/ecore/ecore_exe.c +++ b/legacy/ecore/src/lib/ecore/ecore_exe.c @@ -207,6 +207,40 @@ _ecore_exe_check_errno(int result, const char *file, int line) * Functions that deal with spawned processes. */ +static int run_pri = ECORE_EXE_PRIORITY_INHERIT; + +/** + * Sets the priority at which to launch processes + * + * This sets the priority of processes run by ecore_exe_run() and + * ecore_exe_pipe_run(). If set to ECORE_EXE_PRIORITY_INHERIT child processes + * inherit the priority of their parent. This is the default. + * + * @param pri value -20 to 19 or ECORE_EXE_PRIORITY_INHERIT + * @ingroup Ecore_Exe_Basic_Group + */ +EAPI void +ecore_exe_run_priority_set(int pri) +{ + run_pri = pri; +} + +/** + * Gets the priority at which to launch processes + * + * This gets ths priority of launched processes. See + * ecore_exe_run_priority_set() for details. This just returns the value set + * by this call. + * + * @return the value set by ecore_exe_run_priority_set() + * @ingroup Ecore_Exe_Basic_Group + */ +EAPI int +ecore_exe_run_priority_get(void) +{ + return run_pri; +} + /** * Spawns a child process. * @@ -352,6 +386,13 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data) } else if (pid == 0) /* child */ { + if (run_pri != ECORE_EXE_PRIORITY_INHERIT) + { + if ((run_pri >= -20) && (run_pri <= 19)) + { + setpriority(PRIO_PROCESS, 0, run_pri); + } + } /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the * second pipe if it's open. On the other hand, there was the * Great FD Leak Scare of '06, so let's be paranoid. */ diff --git a/legacy/ecore/src/lib/ecore/ecore_main.c b/legacy/ecore/src/lib/ecore/ecore_main.c index 38dc00654c..caea968619 100644 --- a/legacy/ecore/src/lib/ecore/ecore_main.c +++ b/legacy/ecore/src/lib/ecore/ecore_main.c @@ -328,7 +328,7 @@ _ecore_main_select(double timeout) fdh = (Ecore_Fd_Handler *)l; if (!fdh->delete_me && fdh->prep_func) - fdh->prep_func (fdh->prep_data, fdh); + fdh->prep_func (fdh->prep_data, fdh); } for (l = (Ecore_List2 *)fd_handlers; l; l = l->next) { @@ -353,6 +353,7 @@ _ecore_main_select(double timeout) } if (_ecore_signal_count_get()) return -1; ret = select(max_fd + 1, &rfds, &wfds, &exfds, t); + _ecore_loop_time = ecore_time_get(); if (ret < 0) { if (errno == EINTR) return -1; @@ -531,7 +532,7 @@ _ecore_main_loop_iterate_internal(int once_only) { double now; - now = ecore_time_get(); + now = ecore_loop_time_get(); while (_ecore_timer_call(now)); _ecore_timer_cleanup(); } diff --git a/legacy/ecore/src/lib/ecore/ecore_private.h b/legacy/ecore/src/lib/ecore/ecore_private.h index 2a77c2d791..f24d988edc 100644 --- a/legacy/ecore/src/lib/ecore/ecore_private.h +++ b/legacy/ecore/src/lib/ecore/ecore_private.h @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -469,5 +470,6 @@ void _ecore_fps_debug_runtime_add(double t); extern int _ecore_fps_debug; +extern double _ecore_loop_time; #endif diff --git a/legacy/ecore/src/lib/ecore/ecore_time.c b/legacy/ecore/src/lib/ecore/ecore_time.c index ca7db2c944..3c0d616632 100644 --- a/legacy/ecore/src/lib/ecore/ecore_time.c +++ b/legacy/ecore/src/lib/ecore/ecore_time.c @@ -13,10 +13,15 @@ #include "Ecore.h" #include "ecore_private.h" + + /* FIXME: clock_gettime() is an option... */ /** * Retrieves the current system time as a floating point value in seconds. + * + * Also see ecore_loop_time_get(). + * * @return The number of seconds since 12.00AM 1st January 1970. * @ingroup Ecore_Time_Group */ @@ -32,3 +37,27 @@ ecore_time_get(void) # error "Your platform isn't supported yet" #endif } + +double _ecore_loop_time = -1.0; + +/** + * Retrieves the time at which the last loop stopped waiting for timeouts or events + * + * This gets the time (since Jan 1st, 1970, 12:00AM) that the main loop ceased + * waiting for timouts and/or events to come in or for signals or any other + * interrupt source. This should be considered a reference point fo all + * time based activity that should calculate its timepoint from the return + * of ecore_loop_time_get(). use this UNLESS you absolutely must get the + * current actual timepoint - then use ecore_time_get(). If this is called + * before any loop has ever been run, then it will call ecore_time_get() for + * you the first time and thus have an initial time reference. + * + * @return The number of seconds since 12.00AM 1st January 1970. + * @ingroup Ecore_Time_Group + */ +EAPI double +ecore_loop_time_get(void) +{ + if (_ecore_loop_time < 0.0) return ecore_time_get(); + return _ecore_loop_time; +}