2017-11-08 22:59:04 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2019-02-20 05:14:13 -08:00
|
|
|
#define EFL_LOOP_PROTECTED
|
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <math.h>
|
2018-02-20 22:44:11 -08:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <errno.h>
|
2017-11-08 22:59:04 -08:00
|
|
|
|
|
|
|
#include "Ecore.h"
|
|
|
|
#include "ecore_private.h"
|
|
|
|
|
|
|
|
#include "ecore_main_common.h"
|
|
|
|
|
|
|
|
typedef struct _Efl_Loop_Promise_Simple_Data Efl_Loop_Promise_Simple_Data;
|
|
|
|
typedef struct _Efl_Internal_Promise Efl_Internal_Promise;
|
|
|
|
|
|
|
|
struct _Efl_Loop_Promise_Simple_Data
|
|
|
|
{
|
|
|
|
union {
|
2017-12-20 23:34:05 -08:00
|
|
|
Efl_Loop_Timer *timer;
|
2017-11-08 22:59:04 -08:00
|
|
|
Ecore_Idler *idler;
|
|
|
|
};
|
|
|
|
Eina_Promise *promise;
|
|
|
|
};
|
|
|
|
GENERIC_ALLOC_SIZE_DECLARE(Efl_Loop_Promise_Simple_Data);
|
|
|
|
|
2018-02-26 21:10:12 -08:00
|
|
|
Eo *_mainloop_singleton = NULL;
|
|
|
|
Efl_Loop_Data *_mainloop_singleton_data = NULL;
|
|
|
|
|
2020-09-20 06:23:26 -07:00
|
|
|
ECORE_API Eo *
|
2018-02-26 21:10:12 -08:00
|
|
|
efl_main_loop_get(void)
|
|
|
|
{
|
2019-02-09 09:45:27 -08:00
|
|
|
return efl_app_main_get();
|
2018-02-26 21:10:12 -08:00
|
|
|
}
|
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_loop_iterate(Eo *obj, Efl_Loop_Data *pd)
|
|
|
|
{
|
|
|
|
_ecore_main_loop_iterate(obj, pd);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
|
|
|
_efl_loop_iterate_may_block(Eo *obj, Efl_Loop_Data *pd, int may_block)
|
|
|
|
{
|
|
|
|
return _ecore_main_loop_iterate_may_block(obj, pd, may_block);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Value *
|
|
|
|
_efl_loop_begin(Eo *obj, Efl_Loop_Data *pd)
|
|
|
|
{
|
|
|
|
_ecore_main_loop_begin(obj, pd);
|
2019-08-26 05:46:32 -07:00
|
|
|
if (pd->thread_children)
|
|
|
|
{
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Eo *child;
|
|
|
|
|
|
|
|
// request all child threads to die and defer the quit until
|
|
|
|
// the children have all died and returned.
|
|
|
|
// run main loop again to clean out children and their exits
|
|
|
|
pd->quit_on_last_thread_child_del = EINA_TRUE;
|
|
|
|
EINA_LIST_FOREACH_SAFE(pd->thread_children, l, ll, child)
|
|
|
|
{
|
|
|
|
Efl_Task_Flags task_flags = efl_task_flags_get(child);
|
|
|
|
|
|
|
|
if (task_flags & EFL_TASK_FLAGS_EXIT_WITH_PARENT)
|
|
|
|
efl_task_end(child);
|
|
|
|
else
|
|
|
|
_efl_thread_child_remove(obj, pd, child);
|
|
|
|
}
|
|
|
|
if (pd->thread_children) _ecore_main_loop_begin(obj, pd);
|
|
|
|
}
|
2017-11-08 22:59:04 -08:00
|
|
|
return &(pd->exit_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_loop_quit(Eo *obj, Efl_Loop_Data *pd, Eina_Value exit_code)
|
|
|
|
{
|
|
|
|
_ecore_main_loop_quit(obj, pd);
|
|
|
|
pd->exit_code = exit_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_loop_time_set(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd, double t)
|
|
|
|
{
|
|
|
|
pd->loop_time = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static double
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_loop_time_get(const Eo *obj EINA_UNUSED, Efl_Loop_Data *pd)
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
|
|
|
return pd->loop_time;
|
|
|
|
}
|
|
|
|
|
2020-09-20 06:23:26 -07:00
|
|
|
ECORE_API void
|
2017-11-08 22:59:04 -08:00
|
|
|
efl_exit(int exit_code)
|
|
|
|
{
|
|
|
|
Eina_Value v = EINA_VALUE_EMPTY;
|
|
|
|
|
|
|
|
eina_value_setup(&v, EINA_VALUE_TYPE_INT);
|
2018-03-11 00:41:30 -08:00
|
|
|
eina_value_set(&v, exit_code);
|
2018-02-26 21:10:12 -08:00
|
|
|
efl_loop_quit(efl_main_loop_get(), v);
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
2020-09-20 06:23:26 -07:00
|
|
|
ECORE_API int
|
2017-11-08 22:59:04 -08:00
|
|
|
efl_loop_exit_code_process(Eina_Value *value)
|
|
|
|
{
|
2018-01-08 13:40:02 -08:00
|
|
|
Eina_Value def = EINA_VALUE_EMPTY;
|
|
|
|
const Eina_Value_Type *t;
|
2017-11-08 22:59:04 -08:00
|
|
|
int r = 0;
|
|
|
|
|
2018-01-08 13:40:02 -08:00
|
|
|
if (value == NULL ||
|
|
|
|
!value->type)
|
|
|
|
{
|
|
|
|
def = eina_value_int_init(0);
|
|
|
|
value = &def;
|
|
|
|
}
|
|
|
|
|
|
|
|
t = eina_value_type_get(value);
|
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
if (t == EINA_VALUE_TYPE_UCHAR ||
|
|
|
|
t == EINA_VALUE_TYPE_USHORT ||
|
|
|
|
t == EINA_VALUE_TYPE_UINT ||
|
|
|
|
t == EINA_VALUE_TYPE_ULONG ||
|
|
|
|
t == EINA_VALUE_TYPE_UINT64 ||
|
|
|
|
t == EINA_VALUE_TYPE_CHAR ||
|
|
|
|
t == EINA_VALUE_TYPE_SHORT ||
|
|
|
|
t == EINA_VALUE_TYPE_INT ||
|
|
|
|
t == EINA_VALUE_TYPE_LONG ||
|
|
|
|
t == EINA_VALUE_TYPE_INT64 ||
|
|
|
|
t == EINA_VALUE_TYPE_FLOAT ||
|
|
|
|
t == EINA_VALUE_TYPE_DOUBLE)
|
|
|
|
{
|
|
|
|
Eina_Value v = EINA_VALUE_EMPTY;
|
|
|
|
|
|
|
|
eina_value_setup(&v, EINA_VALUE_TYPE_INT);
|
2018-02-27 04:19:17 -08:00
|
|
|
if (!eina_value_convert(value, &v)) r = -1;
|
|
|
|
else eina_value_get(&v, &r);
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FILE *out = stdout;
|
|
|
|
char *msg;
|
|
|
|
|
|
|
|
msg = eina_value_to_string(value);
|
|
|
|
|
|
|
|
if (t == EINA_VALUE_TYPE_ERROR)
|
|
|
|
{
|
|
|
|
r = -1;
|
|
|
|
out = stderr;
|
|
|
|
}
|
|
|
|
fprintf(out, "%s\n", msg);
|
2019-01-11 17:58:23 -08:00
|
|
|
free(msg);
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_poll_trigger(void *data, const Efl_Event *event)
|
|
|
|
{
|
|
|
|
Eo *parent = efl_parent_get(event->object);
|
|
|
|
|
|
|
|
efl_event_callback_call(parent, data, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_check_event_catcher_add(void *data, const Efl_Event *event)
|
|
|
|
{
|
2018-02-27 04:19:17 -08:00
|
|
|
const Efl_Callback_Array_Item_Full *array = event->info;
|
2017-11-08 22:59:04 -08:00
|
|
|
Efl_Loop_Data *pd = data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; array[i].desc != NULL; i++)
|
|
|
|
{
|
|
|
|
if (array[i].desc == EFL_LOOP_EVENT_IDLE)
|
|
|
|
{
|
|
|
|
++pd->idlers;
|
|
|
|
}
|
|
|
|
// XXX: all the below are kind of bad. ecore_pollers were special.
|
|
|
|
// they all woke up at the SAME time based on interval, (all pollers
|
|
|
|
// of interval 1 woke up together, those with 2 woke up when 1 and
|
|
|
|
// 2 woke up, 4 woke up together along with 1 and 2 etc.
|
|
|
|
// the below means they will just go off whenever but at a pre
|
|
|
|
// defined interval - 1/60th, 6 and 66 seconds. not really great
|
|
|
|
// pollers probably should be less frequent that 1/60th even on poll
|
|
|
|
// high, medium probably down to 1-2 sec and low - yes maybe 30 or 60
|
|
|
|
// sec... still - not timed to wake up together. :(
|
|
|
|
else if (array[i].desc == EFL_LOOP_EVENT_POLL_HIGH)
|
|
|
|
{
|
|
|
|
if (!pd->poll_high)
|
|
|
|
{
|
|
|
|
// Would be better to have it in sync with normal wake up
|
|
|
|
// of the main loop for better energy efficiency, I guess.
|
|
|
|
pd->poll_high = efl_add
|
|
|
|
(EFL_LOOP_TIMER_CLASS, event->object,
|
|
|
|
efl_event_callback_add(efl_added,
|
2019-03-08 07:33:05 -08:00
|
|
|
EFL_LOOP_TIMER_EVENT_TIMER_TICK,
|
2017-11-08 22:59:04 -08:00
|
|
|
_poll_trigger,
|
|
|
|
EFL_LOOP_EVENT_POLL_HIGH),
|
|
|
|
efl_loop_timer_interval_set(efl_added, 1.0 / 60.0));
|
|
|
|
}
|
|
|
|
++pd->pollers.high;
|
|
|
|
}
|
|
|
|
else if (array[i].desc == EFL_LOOP_EVENT_POLL_MEDIUM)
|
|
|
|
{
|
|
|
|
if (!pd->poll_medium)
|
|
|
|
{
|
|
|
|
pd->poll_medium = efl_add
|
|
|
|
(EFL_LOOP_TIMER_CLASS, event->object,
|
|
|
|
efl_event_callback_add(efl_added,
|
2019-03-08 07:33:05 -08:00
|
|
|
EFL_LOOP_TIMER_EVENT_TIMER_TICK,
|
2017-11-08 22:59:04 -08:00
|
|
|
_poll_trigger,
|
|
|
|
EFL_LOOP_EVENT_POLL_MEDIUM),
|
|
|
|
efl_loop_timer_interval_set(efl_added, 6));
|
|
|
|
}
|
|
|
|
++pd->pollers.medium;
|
|
|
|
}
|
|
|
|
else if (array[i].desc == EFL_LOOP_EVENT_POLL_LOW)
|
|
|
|
{
|
|
|
|
if (!pd->poll_low)
|
|
|
|
{
|
|
|
|
pd->poll_low = efl_add
|
|
|
|
(EFL_LOOP_TIMER_CLASS, event->object,
|
|
|
|
efl_event_callback_add(efl_added,
|
2019-03-08 07:33:05 -08:00
|
|
|
EFL_LOOP_TIMER_EVENT_TIMER_TICK,
|
2017-11-08 22:59:04 -08:00
|
|
|
_poll_trigger,
|
|
|
|
EFL_LOOP_EVENT_POLL_LOW),
|
|
|
|
efl_loop_timer_interval_set(efl_added, 66));
|
|
|
|
}
|
|
|
|
++pd->pollers.low;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_check_event_catcher_del(void *data, const Efl_Event *event)
|
|
|
|
{
|
2018-02-27 04:19:17 -08:00
|
|
|
const Efl_Callback_Array_Item_Full *array = event->info;
|
2017-11-08 22:59:04 -08:00
|
|
|
Efl_Loop_Data *pd = data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; array[i].desc != NULL; i++)
|
|
|
|
{
|
|
|
|
if (array[i].desc == EFL_LOOP_EVENT_IDLE)
|
|
|
|
{
|
|
|
|
--pd->idlers;
|
|
|
|
}
|
|
|
|
else if (array[i].desc == EFL_LOOP_EVENT_POLL_HIGH)
|
|
|
|
{
|
|
|
|
--pd->pollers.high;
|
|
|
|
if (!pd->pollers.high)
|
|
|
|
{
|
2017-12-20 23:34:05 -08:00
|
|
|
efl_del(pd->poll_high);
|
2017-11-08 22:59:04 -08:00
|
|
|
pd->poll_high = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (array[i].desc == EFL_LOOP_EVENT_POLL_MEDIUM)
|
|
|
|
{
|
|
|
|
--pd->pollers.medium;
|
|
|
|
if (!pd->pollers.medium)
|
|
|
|
{
|
2017-12-20 23:34:05 -08:00
|
|
|
efl_del(pd->poll_medium);
|
2017-11-08 22:59:04 -08:00
|
|
|
pd->poll_medium = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (array[i].desc == EFL_LOOP_EVENT_POLL_LOW)
|
|
|
|
{
|
|
|
|
--pd->pollers.low;
|
|
|
|
if (!pd->pollers.low)
|
|
|
|
{
|
2017-12-20 23:34:05 -08:00
|
|
|
efl_del(pd->poll_low);
|
2017-11-08 22:59:04 -08:00
|
|
|
pd->poll_low = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EFL_CALLBACKS_ARRAY_DEFINE(event_catcher_watch,
|
|
|
|
{ EFL_EVENT_CALLBACK_ADD, _check_event_catcher_add },
|
|
|
|
{ EFL_EVENT_CALLBACK_DEL, _check_event_catcher_del });
|
|
|
|
|
|
|
|
EOLIAN static Efl_Object *
|
|
|
|
_efl_loop_efl_object_constructor(Eo *obj, Efl_Loop_Data *pd)
|
|
|
|
{
|
|
|
|
obj = efl_constructor(efl_super(obj, EFL_LOOP_CLASS));
|
|
|
|
if (!obj) return NULL;
|
|
|
|
|
|
|
|
efl_event_callback_array_add(obj, event_catcher_watch(), pd);
|
|
|
|
|
|
|
|
pd->loop_time = ecore_time_get();
|
|
|
|
pd->epoll_fd = -1;
|
|
|
|
pd->timer_fd = -1;
|
2019-02-21 09:56:00 -08:00
|
|
|
pd->future_message_handler = efl_add(EFL_LOOP_MESSAGE_FUTURE_HANDLER_CLASS, obj);
|
2019-07-11 15:18:34 -07:00
|
|
|
efl_provider_register(obj, EFL_LOOP_MESSAGE_FUTURE_HANDLER_CLASS, pd->future_message_handler);
|
2019-02-21 09:56:00 -08:00
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-05-01 14:21:49 -07:00
|
|
|
_efl_loop_efl_object_invalidate(Eo *obj, Efl_Loop_Data *pd)
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
2018-05-02 13:19:35 -07:00
|
|
|
efl_invalidate(efl_super(obj, EFL_LOOP_CLASS));
|
|
|
|
|
2018-02-27 04:19:17 -08:00
|
|
|
_ecore_main_content_clear(obj, pd);
|
2017-11-08 22:59:04 -08:00
|
|
|
|
|
|
|
pd->poll_low = NULL;
|
|
|
|
pd->poll_medium = NULL;
|
|
|
|
pd->poll_high = NULL;
|
|
|
|
|
2018-05-01 14:21:49 -07:00
|
|
|
// After invalidate, it won't be possible to parent to the singleton anymore
|
|
|
|
if (obj == _mainloop_singleton)
|
|
|
|
{
|
|
|
|
_mainloop_singleton = NULL;
|
|
|
|
_mainloop_singleton_data = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_loop_efl_object_destructor(Eo *obj, Efl_Loop_Data *pd)
|
|
|
|
{
|
|
|
|
pd->future_message_handler = NULL;
|
2019-08-26 05:46:32 -07:00
|
|
|
while (pd->thread_children)
|
|
|
|
_efl_thread_child_remove(obj, pd, pd->thread_children->data);
|
2018-02-26 09:16:20 -08:00
|
|
|
efl_destructor(efl_super(obj, EFL_LOOP_CLASS));
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
2017-12-15 19:01:30 -08:00
|
|
|
static Eina_Value
|
2018-12-07 03:29:22 -08:00
|
|
|
_efl_loop_arguments_send(Eo *o EINA_UNUSED, void *data, const Eina_Value v)
|
2017-12-15 19:01:30 -08:00
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
|
|
|
static Eina_Bool initialization = EINA_TRUE;
|
|
|
|
Efl_Loop_Arguments arge;
|
|
|
|
Eina_Array *arga = data;
|
|
|
|
|
|
|
|
arge.argv = arga;
|
|
|
|
arge.initialization = initialization;
|
|
|
|
initialization = EINA_FALSE;
|
|
|
|
|
2018-02-26 21:10:12 -08:00
|
|
|
efl_event_callback_call(efl_main_loop_get(),
|
2017-11-08 22:59:04 -08:00
|
|
|
EFL_LOOP_EVENT_ARGUMENTS, &arge);
|
2017-12-15 19:01:30 -08:00
|
|
|
return v;
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
2018-12-07 03:29:22 -08:00
|
|
|
static void
|
|
|
|
_efl_loop_arguments_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eina_Array *arga = data;
|
|
|
|
Eina_Stringshare *s;
|
|
|
|
|
|
|
|
while ((s = eina_array_pop(arga))) eina_stringshare_del(s);
|
|
|
|
eina_array_free(arga);
|
|
|
|
}
|
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
// It doesn't make sense to send those argument to any other mainloop
|
|
|
|
// As it also doesn't make sense to allow anyone to override this, so
|
|
|
|
// should be internal for sure, not even protected.
|
2020-09-20 06:23:26 -07:00
|
|
|
ECORE_API void
|
2017-11-08 22:59:04 -08:00
|
|
|
ecore_loop_arguments_send(int argc, const char **argv)
|
|
|
|
{
|
Revert "Revert command line array object because it's broken by design"
This reverts commit a57c7f751023fe1d1edeabbf8683574ac7497e5e.
I pretty much hate to just revert your revert, but you failed to read my
replies, and failed to understand what i was talking about.
And YES we talked at fosdem about the platform issue, and do you
remember my answer, that back in time this might be the case, today is
different freebsd suppoerts setenv, and for windows we have a setenv
implementation in evil. And yes, vtorri also created a issue how bad and
evil this commit is, however, i still fail to see the issue since setenv
unsetenv and clearenv usages are taken as needed. (T7693)
The ownership question is answered in
https://phab.enlightenment.org/D7516#137367.
Can we please get into a state of technical discussions, and not *oh
shit, i am going to revert this* this has been in review for a long
time, a lots of people have tested it, we discussed things on it, and
there was 3 weeks of no reply from you.
The issues that exist will be dealed with. Feel free to create tasks if
you want :)
2019-02-12 12:34:30 -08:00
|
|
|
Eina_Array *arga, *cml;
|
2017-11-08 22:59:04 -08:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
arga = eina_array_new(argc);
|
Revert "Revert command line array object because it's broken by design"
This reverts commit a57c7f751023fe1d1edeabbf8683574ac7497e5e.
I pretty much hate to just revert your revert, but you failed to read my
replies, and failed to understand what i was talking about.
And YES we talked at fosdem about the platform issue, and do you
remember my answer, that back in time this might be the case, today is
different freebsd suppoerts setenv, and for windows we have a setenv
implementation in evil. And yes, vtorri also created a issue how bad and
evil this commit is, however, i still fail to see the issue since setenv
unsetenv and clearenv usages are taken as needed. (T7693)
The ownership question is answered in
https://phab.enlightenment.org/D7516#137367.
Can we please get into a state of technical discussions, and not *oh
shit, i am going to revert this* this has been in review for a long
time, a lots of people have tested it, we discussed things on it, and
there was 3 weeks of no reply from you.
The issues that exist will be dealed with. Feel free to create tasks if
you want :)
2019-02-12 12:34:30 -08:00
|
|
|
cml = eina_array_new(argc);
|
2017-11-08 22:59:04 -08:00
|
|
|
for (i = 0; i < argc; i++)
|
2018-02-20 22:44:11 -08:00
|
|
|
{
|
2019-02-14 03:28:23 -08:00
|
|
|
Eina_Stringshare *arg;
|
|
|
|
|
|
|
|
arg = eina_stringshare_add(argv[i]);
|
Revert "Revert command line array object because it's broken by design"
This reverts commit a57c7f751023fe1d1edeabbf8683574ac7497e5e.
I pretty much hate to just revert your revert, but you failed to read my
replies, and failed to understand what i was talking about.
And YES we talked at fosdem about the platform issue, and do you
remember my answer, that back in time this might be the case, today is
different freebsd suppoerts setenv, and for windows we have a setenv
implementation in evil. And yes, vtorri also created a issue how bad and
evil this commit is, however, i still fail to see the issue since setenv
unsetenv and clearenv usages are taken as needed. (T7693)
The ownership question is answered in
https://phab.enlightenment.org/D7516#137367.
Can we please get into a state of technical discussions, and not *oh
shit, i am going to revert this* this has been in review for a long
time, a lots of people have tested it, we discussed things on it, and
there was 3 weeks of no reply from you.
The issues that exist will be dealed with. Feel free to create tasks if
you want :)
2019-02-12 12:34:30 -08:00
|
|
|
eina_array_push(arga, arg);
|
2019-02-14 03:28:23 -08:00
|
|
|
arg = eina_stringshare_add(argv[i]);
|
Revert "Revert command line array object because it's broken by design"
This reverts commit a57c7f751023fe1d1edeabbf8683574ac7497e5e.
I pretty much hate to just revert your revert, but you failed to read my
replies, and failed to understand what i was talking about.
And YES we talked at fosdem about the platform issue, and do you
remember my answer, that back in time this might be the case, today is
different freebsd suppoerts setenv, and for windows we have a setenv
implementation in evil. And yes, vtorri also created a issue how bad and
evil this commit is, however, i still fail to see the issue since setenv
unsetenv and clearenv usages are taken as needed. (T7693)
The ownership question is answered in
https://phab.enlightenment.org/D7516#137367.
Can we please get into a state of technical discussions, and not *oh
shit, i am going to revert this* this has been in review for a long
time, a lots of people have tested it, we discussed things on it, and
there was 3 weeks of no reply from you.
The issues that exist will be dealed with. Feel free to create tasks if
you want :)
2019-02-12 12:34:30 -08:00
|
|
|
eina_array_push(cml, arg);
|
2018-02-20 22:44:11 -08:00
|
|
|
}
|
2017-11-08 22:59:04 -08:00
|
|
|
|
2019-02-09 09:45:27 -08:00
|
|
|
efl_core_command_line_command_array_set(efl_app_main_get(), cml);
|
2018-12-07 03:29:22 -08:00
|
|
|
efl_future_then(efl_main_loop_get(), efl_loop_job(efl_main_loop_get()),
|
|
|
|
.success = _efl_loop_arguments_send,
|
|
|
|
.free = _efl_loop_arguments_cleanup,
|
|
|
|
.data = arga);
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Future *
|
|
|
|
_efl_loop_job(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
// NOTE: Eolian should do efl_future_then() to bind future to object.
|
2018-12-07 03:29:22 -08:00
|
|
|
return efl_future_then(obj,
|
|
|
|
eina_future_resolved(efl_loop_future_scheduler_get(obj), EINA_VALUE_EMPTY));
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_loop_throttle_set(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd, double amount)
|
|
|
|
{
|
|
|
|
pd->throttle = ((double)amount) * 1000000.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static double
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_loop_throttle_get(const Eo *obj EINA_UNUSED, Efl_Loop_Data *pd)
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
|
|
|
return (double)(pd->throttle) / 1000000.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_loop_idle_cancel(void *data, const Eina_Promise *dead_ptr EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Efl_Loop_Promise_Simple_Data *d = data;
|
2018-03-03 00:15:10 -08:00
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
ecore_idler_del(d->idler);
|
2018-03-03 00:15:10 -08:00
|
|
|
d->idler = NULL;
|
|
|
|
d->promise = NULL;
|
2017-11-08 22:59:04 -08:00
|
|
|
efl_loop_promise_simple_data_mp_free(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_efl_loop_idle_done(void *data)
|
|
|
|
{
|
|
|
|
Efl_Loop_Promise_Simple_Data *d = data;
|
|
|
|
eina_promise_resolve(d->promise, EINA_VALUE_EMPTY);
|
2018-03-03 00:15:10 -08:00
|
|
|
d->idler = NULL;
|
|
|
|
d->promise = NULL;
|
2017-11-08 22:59:04 -08:00
|
|
|
efl_loop_promise_simple_data_mp_free(d);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Future *
|
|
|
|
_efl_loop_idle(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Efl_Loop_Promise_Simple_Data *d;
|
|
|
|
Eina_Promise *p;
|
2017-12-27 08:19:52 -08:00
|
|
|
Eina_Future_Scheduler *sched = efl_loop_future_scheduler_get(obj);
|
2017-11-08 22:59:04 -08:00
|
|
|
|
|
|
|
d = efl_loop_promise_simple_data_calloc(1);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
|
|
|
|
|
|
|
|
d->idler = ecore_idler_add(_efl_loop_idle_done, d);
|
|
|
|
EINA_SAFETY_ON_NULL_GOTO(d->idler, idler_error);
|
|
|
|
|
2017-12-27 08:19:52 -08:00
|
|
|
p = eina_promise_new(sched, _efl_loop_idle_cancel, d);
|
2017-11-08 22:59:04 -08:00
|
|
|
// d is dead if p is NULL
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(p, NULL);
|
|
|
|
d->promise = p;
|
|
|
|
|
|
|
|
// NOTE: Eolian should do efl_future_then() to bind future to object.
|
2018-11-21 17:33:10 -08:00
|
|
|
return efl_future_then(obj, eina_future_new(p));
|
2017-11-08 22:59:04 -08:00
|
|
|
|
|
|
|
idler_error:
|
2018-03-03 00:15:10 -08:00
|
|
|
d->idler = NULL;
|
|
|
|
d->promise = NULL;
|
2017-11-08 22:59:04 -08:00
|
|
|
efl_loop_promise_simple_data_mp_free(d);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_loop_timeout_cancel(void *data, const Eina_Promise *dead_ptr EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Efl_Loop_Promise_Simple_Data *d = data;
|
2018-01-10 18:14:25 -08:00
|
|
|
|
2017-12-27 08:19:52 -08:00
|
|
|
if (d->timer)
|
2018-01-10 18:14:25 -08:00
|
|
|
efl_del(d->timer);
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
2017-12-20 23:34:05 -08:00
|
|
|
static void
|
|
|
|
_efl_loop_timeout_done(void *data, const Efl_Event *event)
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
|
|
|
Efl_Loop_Promise_Simple_Data *d = data;
|
2017-12-20 23:34:05 -08:00
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
eina_promise_resolve(d->promise, EINA_VALUE_EMPTY);
|
2017-12-20 23:34:05 -08:00
|
|
|
d->timer = NULL;
|
|
|
|
efl_del(event->object);
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
2017-12-27 08:19:52 -08:00
|
|
|
static void
|
|
|
|
_efl_loop_timeout_del(void *data, const Efl_Event *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Efl_Loop_Promise_Simple_Data *d = data;
|
2018-01-10 18:14:25 -08:00
|
|
|
|
2017-12-27 08:19:52 -08:00
|
|
|
d->timer = NULL;
|
2018-03-03 00:15:10 -08:00
|
|
|
d->promise = NULL;
|
2018-01-10 18:14:25 -08:00
|
|
|
efl_loop_promise_simple_data_mp_free(d);
|
2017-12-27 08:19:52 -08:00
|
|
|
}
|
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
static Eina_Future *
|
2017-12-20 23:34:05 -08:00
|
|
|
_efl_loop_timeout(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, double tim)
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
|
|
|
Efl_Loop_Promise_Simple_Data *d;
|
|
|
|
Eina_Promise *p;
|
2017-12-27 08:19:52 -08:00
|
|
|
Eina_Future_Scheduler *sched = efl_loop_future_scheduler_get(obj);
|
2017-11-08 22:59:04 -08:00
|
|
|
|
|
|
|
d = efl_loop_promise_simple_data_calloc(1);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
|
|
|
|
|
2017-12-20 23:34:05 -08:00
|
|
|
d->timer = efl_add(EFL_LOOP_TIMER_CLASS, obj,
|
|
|
|
efl_loop_timer_interval_set(efl_added, tim),
|
|
|
|
efl_event_callback_add(efl_added,
|
2019-03-08 07:33:05 -08:00
|
|
|
EFL_LOOP_TIMER_EVENT_TIMER_TICK,
|
2017-12-27 08:19:52 -08:00
|
|
|
_efl_loop_timeout_done, d),
|
|
|
|
efl_event_callback_add(efl_added,
|
|
|
|
EFL_EVENT_DEL,
|
|
|
|
_efl_loop_timeout_del, d)
|
|
|
|
);
|
2017-11-08 22:59:04 -08:00
|
|
|
EINA_SAFETY_ON_NULL_GOTO(d->timer, timer_error);
|
|
|
|
|
2017-12-27 08:19:52 -08:00
|
|
|
p = eina_promise_new(sched, _efl_loop_timeout_cancel, d);
|
2017-11-08 22:59:04 -08:00
|
|
|
// d is dead if p is NULL
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(p, NULL);
|
|
|
|
d->promise = p;
|
|
|
|
|
|
|
|
// NOTE: Eolian should do efl_future_then() to bind future to object.
|
2018-11-21 17:33:10 -08:00
|
|
|
return efl_future_then(obj, eina_future_new(p));
|
2017-11-08 22:59:04 -08:00
|
|
|
|
|
|
|
timer_error:
|
2018-03-03 00:15:10 -08:00
|
|
|
d->timer = NULL;
|
|
|
|
d->promise = NULL;
|
2017-11-08 22:59:04 -08:00
|
|
|
efl_loop_promise_simple_data_mp_free(d);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2019-07-11 14:59:05 -07:00
|
|
|
_efl_loop_register(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED,
|
|
|
|
const Efl_Class *klass, const Efl_Object *provider)
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
2019-07-11 14:59:05 -07:00
|
|
|
return efl_provider_register(obj, klass, provider);
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
2019-07-11 15:34:31 -07:00
|
|
|
EFL_FUNC_BODYV(efl_loop_register, Eina_Bool, EINA_FALSE, EFL_FUNC_CALL(klass, provider), const Efl_Class *klass, const Efl_Object *provider);
|
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
static Eina_Bool
|
2019-07-11 14:59:05 -07:00
|
|
|
_efl_loop_unregister(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED,
|
|
|
|
const Efl_Class *klass, const Efl_Object *provider)
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
2019-07-11 14:59:05 -07:00
|
|
|
return efl_provider_unregister(obj, klass, provider);
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
2019-07-11 15:34:31 -07:00
|
|
|
EFL_FUNC_BODYV(efl_loop_unregister, Eina_Bool, EINA_FALSE, EFL_FUNC_CALL(klass, provider), const Efl_Class *klass, const Efl_Object *provider);
|
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
void
|
|
|
|
_efl_loop_messages_filter(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd, void *handler_pd)
|
|
|
|
{
|
|
|
|
Message *msg;
|
|
|
|
|
|
|
|
pd->message_walking++;
|
|
|
|
EINA_INLIST_FOREACH(pd->message_queue, msg)
|
|
|
|
{
|
|
|
|
if ((msg->handler) && (msg->message) && (!msg->delete_me))
|
|
|
|
{
|
|
|
|
if (!_ecore_event_do_filter(handler_pd,
|
|
|
|
msg->handler, msg->message))
|
|
|
|
{
|
|
|
|
efl_del(msg->message);
|
|
|
|
msg->handler = NULL;
|
|
|
|
msg->message = NULL;
|
|
|
|
msg->delete_me = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pd->message_walking--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_efl_loop_messages_call(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd, void *func, void *data)
|
|
|
|
{
|
|
|
|
Message *msg;
|
|
|
|
|
|
|
|
pd->message_walking++;
|
|
|
|
EINA_INLIST_FOREACH(pd->message_queue, msg)
|
|
|
|
{
|
|
|
|
if ((msg->handler) && (msg->message) && (!msg->delete_me))
|
|
|
|
{
|
|
|
|
Eina_Bool (*fn) (void *data, void *handler, void *msg);
|
|
|
|
|
|
|
|
fn = func;
|
|
|
|
if (!fn(data, msg->handler, msg->message))
|
|
|
|
{
|
|
|
|
efl_del(msg->message);
|
|
|
|
msg->handler = NULL;
|
|
|
|
msg->message = NULL;
|
|
|
|
msg->delete_me = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pd->message_walking--;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_loop_message_process(Eo *obj, Efl_Loop_Data *pd)
|
|
|
|
{
|
|
|
|
if (!pd->message_queue) return EINA_FALSE;
|
|
|
|
pd->message_walking++;
|
|
|
|
_ecore_event_filters_call(obj, pd);
|
|
|
|
while (pd->message_queue)
|
|
|
|
{
|
|
|
|
Message *msg = (Message *)pd->message_queue;
|
|
|
|
if (!msg->delete_me)
|
|
|
|
efl_loop_message_handler_message_call(msg->handler, msg->message);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (msg->message) efl_del(msg->message);
|
|
|
|
pd->message_queue =
|
|
|
|
eina_inlist_remove(pd->message_queue,
|
|
|
|
pd->message_queue);
|
|
|
|
free(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pd->message_walking--;
|
|
|
|
if (pd->message_walking == 0)
|
|
|
|
{
|
|
|
|
Message *msg;
|
|
|
|
|
|
|
|
EINA_INLIST_FREE(pd->message_queue, msg)
|
|
|
|
{
|
|
|
|
if (msg->message)
|
|
|
|
{
|
|
|
|
if (!msg->delete_me)
|
|
|
|
ERR("Found unprocessed event msg=%p handler=%p on queue",
|
|
|
|
msg->message, msg->handler);
|
|
|
|
efl_del(msg->message);
|
|
|
|
}
|
|
|
|
else free(msg);
|
|
|
|
}
|
2019-10-24 00:27:37 -07:00
|
|
|
|
|
|
|
while (pd->message_pending_queue)
|
|
|
|
{
|
|
|
|
msg = (Message *)pd->message_pending_queue;
|
|
|
|
pd->message_pending_queue = eina_inlist_remove(pd->message_pending_queue,
|
|
|
|
pd->message_pending_queue);
|
|
|
|
pd->message_queue = eina_inlist_append(pd->message_queue, EINA_INLIST_GET(msg));
|
|
|
|
}
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2020-09-20 06:23:26 -07:00
|
|
|
ECORE_API ECORE_API_WEAK EFL_FUNC_BODY(efl_loop_message_process, Eina_Bool, 0);
|
2017-12-18 16:10:11 -08:00
|
|
|
|
2020-09-20 06:23:26 -07:00
|
|
|
ECORE_API ECORE_API_WEAK void
|
2018-02-26 21:10:12 -08:00
|
|
|
efl_build_version_set(int vmaj, int vmin, int vmic, int revision,
|
|
|
|
const char *flavor, const char *build_id)
|
|
|
|
{
|
|
|
|
// note: EFL has not been initialized yet at this point (ie. no eina call)
|
|
|
|
_app_efl_version.major = vmaj;
|
|
|
|
_app_efl_version.minor = vmin;
|
|
|
|
_app_efl_version.micro = vmic;
|
|
|
|
_app_efl_version.revision = revision;
|
|
|
|
free((char *)_app_efl_version.flavor);
|
|
|
|
free((char *)_app_efl_version.build_id);
|
|
|
|
_app_efl_version.flavor = flavor ? strdup(flavor) : NULL;
|
|
|
|
_app_efl_version.build_id = build_id ? strdup(build_id) : NULL;
|
|
|
|
}
|
|
|
|
|
2019-09-10 15:01:19 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-02-27 04:19:17 -08:00
|
|
|
_efl_loop_efl_task_run(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED)
|
2018-02-20 22:44:11 -08:00
|
|
|
{
|
2019-09-10 15:01:19 -07:00
|
|
|
efl_loop_exit_code_process(efl_loop_begin(obj));
|
|
|
|
return EINA_TRUE;
|
2018-02-20 22:44:11 -08:00
|
|
|
}
|
|
|
|
|
2018-02-27 04:19:17 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_loop_efl_task_end(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED)
|
2018-02-20 22:44:11 -08:00
|
|
|
{
|
2018-02-27 04:19:17 -08:00
|
|
|
efl_loop_quit(obj, eina_value_int_init(0));
|
2018-02-20 22:44:11 -08:00
|
|
|
}
|
|
|
|
|
2019-10-16 16:47:47 -07:00
|
|
|
EFL_SCHEDULER_ARRAY_DEFINE(loop_scheduler,
|
|
|
|
EFL_LOOP_EVENT_IDLE_ENTER,
|
|
|
|
EFL_LOOP_EVENT_IDLE);
|
|
|
|
|
2020-09-20 06:23:26 -07:00
|
|
|
ECORE_API Eina_Future_Scheduler *
|
2018-01-03 11:35:08 -08:00
|
|
|
efl_loop_future_scheduler_get(const Eo *obj)
|
2017-11-08 22:59:04 -08:00
|
|
|
{
|
2018-01-04 11:21:36 -08:00
|
|
|
Efl_Loop *loop;
|
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
if (!obj) return NULL;
|
|
|
|
|
|
|
|
if (efl_isa(obj, EFL_LOOP_CLASS))
|
2017-12-27 08:19:52 -08:00
|
|
|
{
|
|
|
|
Efl_Loop_Data *pd = efl_data_scope_get(obj, EFL_LOOP_CLASS);
|
|
|
|
|
|
|
|
if (!pd) return NULL;
|
2019-10-16 16:47:47 -07:00
|
|
|
return efl_event_future_scheduler_get(obj, loop_scheduler());
|
2017-12-27 08:19:52 -08:00
|
|
|
}
|
2018-01-04 11:21:36 -08:00
|
|
|
if (efl_isa(obj, EFL_LOOP_CONSUMER_CLASS))
|
|
|
|
return efl_loop_future_scheduler_get(efl_loop_get(obj));
|
|
|
|
|
|
|
|
loop = efl_provider_find(obj, EFL_LOOP_CLASS);
|
|
|
|
if (loop)
|
|
|
|
return efl_loop_future_scheduler_get(loop);
|
2017-11-08 22:59:04 -08:00
|
|
|
|
2018-01-04 11:21:36 -08:00
|
|
|
return NULL;
|
2017-11-08 22:59:04 -08:00
|
|
|
}
|
|
|
|
|
2019-07-11 15:34:31 -07:00
|
|
|
#define EFL_LOOP_EXTRA_OPS \
|
|
|
|
EFL_OBJECT_OP_FUNC(efl_loop_message_process, _efl_loop_message_process), \
|
|
|
|
EFL_OBJECT_OP_FUNC(efl_loop_register, _efl_loop_register), \
|
|
|
|
EFL_OBJECT_OP_FUNC(efl_loop_unregister, _efl_loop_unregister)
|
2017-12-18 16:10:11 -08:00
|
|
|
|
2017-11-08 22:59:04 -08:00
|
|
|
#include "efl_loop.eo.c"
|