#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. */
#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);
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);
* 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.
*
}
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. */
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)
{
}
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;
{
double now;
- now = ecore_time_get();
+ now = ecore_loop_time_get();
while (_ecore_timer_call(now));
_ecore_timer_cleanup();
}
#include <fcntl.h>
#include <limits.h>
#include <dirent.h>
+#include <sys/resource.h>
#include <eina_types.h>
extern int _ecore_fps_debug;
+extern double _ecore_loop_time;
#endif
#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
*/
# 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;
+}