forked from enlightenment/efl
Eolian: Integration of Ecore Idler
This commit is contained in:
parent
f9a54462c0
commit
753a4b3106
|
@ -7,13 +7,16 @@ BUILT_SOURCES += \
|
||||||
lib/ecore/ecore_poll.eo.c \
|
lib/ecore/ecore_poll.eo.c \
|
||||||
lib/ecore/ecore_poll.eo.h \
|
lib/ecore/ecore_poll.eo.h \
|
||||||
lib/ecore/ecore_job.eo.c \
|
lib/ecore/ecore_job.eo.c \
|
||||||
lib/ecore/ecore_job.eo.h
|
lib/ecore/ecore_job.eo.h \
|
||||||
|
lib/ecore/ecore_idler.eo.c \
|
||||||
|
lib/ecore/ecore_idler.eo.h
|
||||||
|
|
||||||
ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
|
ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
|
||||||
ecoreeolianfiles_DATA = \
|
ecoreeolianfiles_DATA = \
|
||||||
lib/ecore/ecore_timer.eo \
|
lib/ecore/ecore_timer.eo \
|
||||||
lib/ecore/ecore_poll.eo \
|
lib/ecore/ecore_poll.eo \
|
||||||
lib/ecore/ecore_job.eo
|
lib/ecore/ecore_job.eo \
|
||||||
|
lib/ecore/ecore_idler.eo
|
||||||
|
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
${ecoreeolianfiles_DATA}
|
${ecoreeolianfiles_DATA}
|
||||||
|
@ -31,7 +34,8 @@ lib/ecore/Ecore_Getopt.h
|
||||||
nodist_installed_ecoremainheaders_DATA = \
|
nodist_installed_ecoremainheaders_DATA = \
|
||||||
lib/ecore/ecore_timer.eo.h \
|
lib/ecore/ecore_timer.eo.h \
|
||||||
lib/ecore/ecore_poll.eo.h \
|
lib/ecore/ecore_poll.eo.h \
|
||||||
lib/ecore/ecore_job.eo.h
|
lib/ecore/ecore_job.eo.h \
|
||||||
|
lib/ecore/ecore_idler.eo.h
|
||||||
|
|
||||||
lib_ecore_libecore_la_SOURCES = \
|
lib_ecore_libecore_la_SOURCES = \
|
||||||
lib/ecore/ecore.c \
|
lib/ecore/ecore.c \
|
||||||
|
|
|
@ -238,6 +238,8 @@ enum
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
#include "ecore_idler.eo.h"
|
||||||
|
#if 0
|
||||||
|
|
||||||
#define ECORE_IDLER_CLASS ecore_idler_class_get()
|
#define ECORE_IDLER_CLASS ecore_idler_class_get()
|
||||||
const Eo_Class *ecore_idler_class_get(void) EINA_CONST;
|
const Eo_Class *ecore_idler_class_get(void) EINA_CONST;
|
||||||
|
@ -264,6 +266,7 @@ enum
|
||||||
*/
|
*/
|
||||||
#define ecore_idler_constructor(func, data) ECORE_IDLER_ID(ECORE_IDLER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
|
#define ecore_idler_constructor(func, data) ECORE_IDLER_ID(ECORE_IDLER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,9 +13,7 @@
|
||||||
|
|
||||||
#define MY_CLASS_NAME "Ecore_Idler"
|
#define MY_CLASS_NAME "Ecore_Idler"
|
||||||
|
|
||||||
EAPI Eo_Op ECORE_IDLER_BASE_ID = EO_NOOP;
|
struct _Ecore_Idler_Data
|
||||||
|
|
||||||
struct _Ecore_Idler_Private_Data
|
|
||||||
{
|
{
|
||||||
EINA_INLIST;
|
EINA_INLIST;
|
||||||
Ecore_Idler *obj;
|
Ecore_Idler *obj;
|
||||||
|
@ -25,9 +23,9 @@ struct _Ecore_Idler_Private_Data
|
||||||
Eina_Bool delete_me : 1;
|
Eina_Bool delete_me : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _Ecore_Idler_Private_Data Ecore_Idler_Private_Data;
|
typedef struct _Ecore_Idler_Data Ecore_Idler_Data;
|
||||||
static Ecore_Idler_Private_Data *idlers = NULL;
|
static Ecore_Idler_Data *idlers = NULL;
|
||||||
static Ecore_Idler_Private_Data *idler_current = NULL;
|
static Ecore_Idler_Data *idler_current = NULL;
|
||||||
static int idlers_delete_me = 0;
|
static int idlers_delete_me = 0;
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@ -48,20 +46,15 @@ ecore_idler_add(Ecore_Task_Cb func,
|
||||||
return ie;
|
return ie;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
EOLIAN static void
|
||||||
_idler_constructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
_ecore_idler_constructor(Eo *obj, Ecore_Idler_Data *ie, Ecore_Task_Cb func, const void *data)
|
||||||
{
|
{
|
||||||
Ecore_Task_Cb func = va_arg(*list, Ecore_Task_Cb);
|
|
||||||
const void *data = va_arg(*list, const void *);
|
|
||||||
|
|
||||||
if (EINA_UNLIKELY(!eina_main_loop_is()))
|
if (EINA_UNLIKELY(!eina_main_loop_is()))
|
||||||
{
|
{
|
||||||
eo_error_set(obj);
|
eo_error_set(obj);
|
||||||
EINA_MAIN_LOOP_CHECK_RETURN;
|
EINA_MAIN_LOOP_CHECK_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ecore_Idler_Private_Data *ie = _pd;
|
|
||||||
|
|
||||||
ie->obj = obj;
|
ie->obj = obj;
|
||||||
eo_do_super(obj, MY_CLASS, eo_constructor());
|
eo_do_super(obj, MY_CLASS, eo_constructor());
|
||||||
eo_manual_free_set(obj, EINA_TRUE);
|
eo_manual_free_set(obj, EINA_TRUE);
|
||||||
|
@ -75,12 +68,11 @@ _idler_constructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||||
|
|
||||||
ie->func = func;
|
ie->func = func;
|
||||||
ie->data = (void *)data;
|
ie->data = (void *)data;
|
||||||
idlers = (Ecore_Idler_Private_Data *)eina_inlist_append(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
|
idlers = (Ecore_Idler_Data *)eina_inlist_append(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
static void
|
_ecore_idler_eo_base_constructor(Eo *obj, Ecore_Idler_Data *_pd EINA_UNUSED)
|
||||||
_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
|
|
||||||
{
|
{
|
||||||
eo_error_set(obj);
|
eo_error_set(obj);
|
||||||
ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME);
|
ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME);
|
||||||
|
@ -111,18 +103,16 @@ ecore_idler_del(Ecore_Idler *idler)
|
||||||
static void *
|
static void *
|
||||||
_ecore_idler_del(Ecore_Idler *obj)
|
_ecore_idler_del(Ecore_Idler *obj)
|
||||||
{
|
{
|
||||||
Ecore_Idler_Private_Data *idler = eo_data_scope_get(obj, MY_CLASS);
|
Ecore_Idler_Data *idler = eo_data_scope_get(obj, MY_CLASS);
|
||||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL);
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL);
|
||||||
idler->delete_me = 1;
|
idler->delete_me = 1;
|
||||||
idlers_delete_me = 1;
|
idlers_delete_me = 1;
|
||||||
return idler->data;
|
return idler->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
EOLIAN static void
|
||||||
_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
_ecore_idler_eo_base_destructor(Eo *obj, Ecore_Idler_Data *idler)
|
||||||
{
|
{
|
||||||
Ecore_Idler_Private_Data *idler = _pd;
|
|
||||||
|
|
||||||
idler->delete_me = 1;
|
idler->delete_me = 1;
|
||||||
idlers_delete_me = 1;
|
idlers_delete_me = 1;
|
||||||
|
|
||||||
|
@ -132,10 +122,10 @@ _destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||||
void
|
void
|
||||||
_ecore_idler_shutdown(void)
|
_ecore_idler_shutdown(void)
|
||||||
{
|
{
|
||||||
Ecore_Idler_Private_Data *ie;
|
Ecore_Idler_Data *ie;
|
||||||
while ((ie = idlers))
|
while ((ie = idlers))
|
||||||
{
|
{
|
||||||
idlers = (Ecore_Idler_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers));
|
idlers = (Ecore_Idler_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers));
|
||||||
|
|
||||||
eo_do(ie->obj, eo_parent_set(NULL));
|
eo_do(ie->obj, eo_parent_set(NULL));
|
||||||
if (eo_destructed_is(ie->obj))
|
if (eo_destructed_is(ie->obj))
|
||||||
|
@ -158,12 +148,12 @@ _ecore_idler_all_call(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* recursive main loop, continue from where we were */
|
/* recursive main loop, continue from where we were */
|
||||||
idler_current = (Ecore_Idler_Private_Data *)EINA_INLIST_GET(idler_current)->next;
|
idler_current = (Ecore_Idler_Data *)EINA_INLIST_GET(idler_current)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (idler_current)
|
while (idler_current)
|
||||||
{
|
{
|
||||||
Ecore_Idler_Private_Data *ie = (Ecore_Idler_Private_Data *)idler_current;
|
Ecore_Idler_Data *ie = (Ecore_Idler_Data *)idler_current;
|
||||||
if (!ie->delete_me)
|
if (!ie->delete_me)
|
||||||
{
|
{
|
||||||
ie->references++;
|
ie->references++;
|
||||||
|
@ -174,16 +164,16 @@ _ecore_idler_all_call(void)
|
||||||
ie->references--;
|
ie->references--;
|
||||||
}
|
}
|
||||||
if (idler_current) /* may have changed in recursive main loops */
|
if (idler_current) /* may have changed in recursive main loops */
|
||||||
idler_current = (Ecore_Idler_Private_Data *)EINA_INLIST_GET(idler_current)->next;
|
idler_current = (Ecore_Idler_Data *)EINA_INLIST_GET(idler_current)->next;
|
||||||
}
|
}
|
||||||
if (idlers_delete_me)
|
if (idlers_delete_me)
|
||||||
{
|
{
|
||||||
Ecore_Idler_Private_Data *l;
|
Ecore_Idler_Data *l;
|
||||||
int deleted_idlers_in_use = 0;
|
int deleted_idlers_in_use = 0;
|
||||||
for (l = idlers; l; )
|
for (l = idlers; l; )
|
||||||
{
|
{
|
||||||
Ecore_Idler_Private_Data *ie = l;
|
Ecore_Idler_Data *ie = l;
|
||||||
l = (Ecore_Idler_Private_Data *)EINA_INLIST_GET(l)->next;
|
l = (Ecore_Idler_Data *)EINA_INLIST_GET(l)->next;
|
||||||
if (ie->delete_me)
|
if (ie->delete_me)
|
||||||
{
|
{
|
||||||
if (ie->references)
|
if (ie->references)
|
||||||
|
@ -192,7 +182,7 @@ _ecore_idler_all_call(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
idlers = (Ecore_Idler_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
|
idlers = (Ecore_Idler_Data *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
|
||||||
|
|
||||||
eo_do(ie->obj, eo_parent_set(NULL));
|
eo_do(ie->obj, eo_parent_set(NULL));
|
||||||
if (eo_destructed_is(ie->obj))
|
if (eo_destructed_is(ie->obj))
|
||||||
|
@ -215,34 +205,4 @@ _ecore_idler_exist(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
#include "ecore_idler.eo.c"
|
||||||
_class_constructor(Eo_Class *klass)
|
|
||||||
{
|
|
||||||
const Eo_Op_Func_Description func_desc[] = {
|
|
||||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
|
|
||||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
|
|
||||||
|
|
||||||
EO_OP_FUNC(ECORE_IDLER_ID(ECORE_IDLER_SUB_ID_CONSTRUCTOR), _idler_constructor),
|
|
||||||
EO_OP_FUNC_SENTINEL
|
|
||||||
};
|
|
||||||
|
|
||||||
eo_class_funcs_set(klass, func_desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const Eo_Op_Description op_desc[] = {
|
|
||||||
EO_OP_DESCRIPTION(ECORE_IDLER_SUB_ID_CONSTRUCTOR, "Add an idler handler."),
|
|
||||||
EO_OP_DESCRIPTION_SENTINEL
|
|
||||||
};
|
|
||||||
|
|
||||||
static const Eo_Class_Description class_desc = {
|
|
||||||
EO_VERSION,
|
|
||||||
MY_CLASS_NAME,
|
|
||||||
EO_CLASS_TYPE_REGULAR,
|
|
||||||
EO_CLASS_DESCRIPTION_OPS(&ECORE_IDLER_BASE_ID, op_desc, ECORE_IDLER_SUB_ID_LAST),
|
|
||||||
NULL,
|
|
||||||
sizeof(Ecore_Idler_Private_Data),
|
|
||||||
_class_constructor,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
EO_DEFINE_CLASS(ecore_idler_class_get, &class_desc, EO_BASE_CLASS, NULL)
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
class Ecore_Idler (Eo_Base)
|
||||||
|
{
|
||||||
|
eo_prefix: ecore_idler;
|
||||||
|
constructors {
|
||||||
|
constructor {
|
||||||
|
/*@ Contructor. */
|
||||||
|
params {
|
||||||
|
@in Ecore_Task_Cb func;
|
||||||
|
@in const void *data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo_Base::constructor;
|
||||||
|
Eo_Base::destructor;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue