forked from enlightenment/efl
new ecore_loop_time_get() call. also priority setting for spawning sub-procs
SVN revision: 37389
This commit is contained in:
parent
f38e74e550
commit
b2edd2d7d6
|
@ -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,6 +285,7 @@ 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);
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <eina_types.h>
|
||||
|
||||
|
@ -469,5 +470,6 @@ void _ecore_fps_debug_runtime_add(double t);
|
|||
|
||||
|
||||
extern int _ecore_fps_debug;
|
||||
extern double _ecore_loop_time;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue