diff options
author | Cedric BAIL <cedric@osg.samsung.com> | 2016-06-16 15:13:22 -0700 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2016-06-22 13:19:13 -0700 |
commit | 10aadafcfd01d972a50fb9e1e6b3d3c28924feb0 (patch) | |
tree | ca3375665c23b8ba1c683c8c97695a37336f3f69 | |
parent | ae207a5be683c3f89087552a11fc7bd91128d71e (diff) | |
download | efl-10aadafcfd01d972a50fb9e1e6b3d3c28924feb0.tar.gz |
eio: rename eio_job to efl_io_manager.
There is still a lot of work to do in this API to make it efficient and
stable. Will try to get at it before 1.18 release.
-rw-r--r-- | src/Makefile_Eio.am | 9 | ||||
-rw-r--r-- | src/lib/eio/Eio_Eo.h | 2 | ||||
-rw-r--r-- | src/lib/eio/efl_io_manager.c (renamed from src/lib/eio/eio_job.c) | 87 | ||||
-rw-r--r-- | src/lib/eio/efl_io_manager.eo (renamed from src/lib/eio/eio_job.eo) | 6 | ||||
-rw-r--r-- | src/lib/eio/eio_job_private.h | 12 | ||||
-rw-r--r-- | src/tests/eio/eio_test_manager.c (renamed from src/tests/eio/eio_test_job.c) | 47 | ||||
-rw-r--r-- | src/tests/eio/eio_test_manager_xattr.c (renamed from src/tests/eio/eio_test_job_xattr.c) | 10 |
7 files changed, 86 insertions, 87 deletions
diff --git a/src/Makefile_Eio.am b/src/Makefile_Eio.am index e8c674ac0b..4c28c8a69d 100644 --- a/src/Makefile_Eio.am +++ b/src/Makefile_Eio.am @@ -3,7 +3,7 @@ eio_eolian_files = \ lib/eio/eio_model.eo \ - lib/eio/eio_job.eo \ + lib/eio/efl_io_manager.eo \ lib/eio/eio_sentry.eo eio_eolian_h = $(eio_eolian_files:%.eo=%.eo.h) @@ -33,7 +33,7 @@ lib_eio_libeio_la_SOURCES = \ lib/eio/eio_dir.c \ lib/eio/eio_eet.c \ lib/eio/eio_file.c \ -lib/eio/eio_job.c \ +lib/eio/efl_io_manager.c \ lib/eio/eio_sentry.c \ lib/eio/eio_main.c \ lib/eio/eio_map.c \ @@ -44,7 +44,6 @@ lib/eio/eio_xattr.c \ lib/eio/eio_model.c \ lib/eio/eio_model_private.h \ lib/eio/eio_private.h \ -lib/eio/eio_job_private.h \ lib/eio/eio_sentry_private.h if HAVE_INOTIFY @@ -83,8 +82,8 @@ tests/eio/eio_model_test_monitor_add.c \ tests/eio/eio_test_monitor.c \ tests/eio/eio_test_sentry.c \ tests/eio/eio_test_file.c \ -tests/eio/eio_test_job.c \ -tests/eio/eio_test_job_xattr.c \ +tests/eio/eio_test_manager.c \ +tests/eio/eio_test_manager_xattr.c \ tests/eio/eio_test_xattr.c \ tests/eio/eio_test_common.c \ tests/eio/eio_test_common.h \ diff --git a/src/lib/eio/Eio_Eo.h b/src/lib/eio/Eio_Eo.h index 3fe3510816..b79f2ab870 100644 --- a/src/lib/eio/Eio_Eo.h +++ b/src/lib/eio/Eio_Eo.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "eio_job.eo.h" +#include "efl_io_manager.eo.h" #include "eio_sentry.eo.h" #include "eio_model.eo.h" diff --git a/src/lib/eio/eio_job.c b/src/lib/eio/efl_io_manager.c index aa98ef414b..436f652085 100644 --- a/src/lib/eio/eio_job.c +++ b/src/lib/eio/efl_io_manager.c @@ -25,26 +25,33 @@ #include <Eo.h> #include "Eio.h" -#include "eio_job_private.h" -typedef Eio_File* (*Eio_Job_Direct_Ls_Func)(const char *path, Eio_Filter_Direct_Cb, Eio_Main_Direct_Cb, Eio_Done_Cb, Eio_Error_Cb, const void *data); +typedef struct _Efl_Io_Manager_Data Efl_Io_Manager_Data; + +struct _Efl_Io_Manager_Data +{ + Eo *object; + Eina_List *operations; +}; + +typedef Eio_File* (*Efl_Io_Manager_Direct_Ls_Func)(const char *path, Eio_Filter_Direct_Cb, Eio_Main_Direct_Cb, Eio_Done_Cb, Eio_Error_Cb, const void *data); typedef struct _Job_Closure Job_Closure; struct _Job_Closure { Eo *object; - Eio_Job_Data *pdata; + Efl_Io_Manager_Data *pdata; Eina_Promise_Owner *promise; Eio_File *file; Eina_Bool delete_me; void *delayed_arg; - Eio_Job_Direct_Ls_Func direct_func; // Used when dispatching direct ls funcs. + Efl_Io_Manager_Direct_Ls_Func direct_func; // Used when dispatching direct ls funcs. }; /* Helper functions */ static Job_Closure * -_job_closure_create(Eo *obj, Eio_Job_Data *pdata, Eina_Promise_Owner *owner) +_job_closure_create(Eo *obj, Efl_Io_Manager_Data *pdata, Eina_Promise_Owner *owner) { EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(pdata, NULL); @@ -75,7 +82,7 @@ static void _job_closure_del(Job_Closure *closure) { EINA_SAFETY_ON_NULL_RETURN(closure); - Eio_Job_Data *pdata = closure->pdata; + Efl_Io_Manager_Data *pdata = closure->pdata; if (pdata) pdata->operations = eina_list_remove(pdata->operations, closure); @@ -129,13 +136,13 @@ _file_ls_filter_cb_helper(const Eo_Event_Description *event, void *data, const c static Eina_Bool _file_ls_filter_xattr_cb(void *data, Eio_File *handler EINA_UNUSED, const char *file) { - return _file_ls_filter_cb_helper(EIO_JOB_EVENT_XATTR, data, file); + return _file_ls_filter_cb_helper(EFL_IO_MANAGER_EVENT_XATTR, data, file); } static Eina_Bool _file_ls_filter_named_cb(void *data, Eio_File *handler EINA_UNUSED, const char *file) { - return _file_ls_filter_cb_helper(EIO_JOB_EVENT_FILTER_NAME, data, file); + return _file_ls_filter_cb_helper(EFL_IO_MANAGER_EVENT_FILTER_NAME, data, file); } static void @@ -206,7 +213,7 @@ _file_direct_ls_filter_cb(void *data, Eio_File *handle EINA_UNUSED, const Eina_F event_info.info = info; event_info.filter = EINA_FALSE; - eo_event_callback_call(operation->pdata->object, EIO_JOB_EVENT_FILTER_DIRECT, &event_info); + eo_event_callback_call(operation->pdata->object, EFL_IO_MANAGER_EVENT_FILTER_DIRECT, &event_info); Eina_Bool filter = event_info.filter; @@ -279,9 +286,9 @@ _xattr_notify_start(void *data, Eina_Promise_Owner *promise EINA_UNUSED) } static void -_job_direct_ls_helper(Eio_Job_Direct_Ls_Func ls_func, +_job_direct_ls_helper(Efl_Io_Manager_Direct_Ls_Func ls_func, Eo* obj, - Eio_Job_Data *pd, + Efl_Io_Manager_Data *pd, const char *path, Eina_Promise_Owner *promise) { @@ -309,8 +316,8 @@ _job_direct_ls_helper(Eio_Job_Direct_Ls_Func ls_func, /* Method implementations */ static Eina_Promise* -_eio_job_file_direct_ls(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_direct_ls(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path) { Eina_Promise_Owner* promise = eina_promise_add(); @@ -319,8 +326,8 @@ _eio_job_file_direct_ls(Eo *obj, } static Eina_Promise* -_eio_job_file_stat_ls(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_stat_ls(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path) { Eina_Promise_Owner* promise = eina_promise_add(); @@ -329,8 +336,8 @@ _eio_job_file_stat_ls(Eo *obj, } static Eina_Promise* -_eio_job_dir_stat_ls(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_dir_stat_ls(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path) { Eina_Promise_Owner* promise = eina_promise_add(); @@ -339,20 +346,20 @@ _eio_job_dir_stat_ls(Eo *obj, } static Eina_Promise* -_eio_job_dir_direct_ls(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_dir_direct_ls(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path) { Eina_Promise_Owner* promise = eina_promise_add(); // Had to add the cast as dir_direct differs in the filter callback constness of one of // its arguments. - _job_direct_ls_helper((Eio_Job_Direct_Ls_Func)&eio_dir_direct_ls, obj, pd, path, promise); + _job_direct_ls_helper((Efl_Io_Manager_Direct_Ls_Func)&eio_dir_direct_ls, obj, pd, path, promise); return eina_promise_owner_promise_get(promise); } static Eina_Promise* -_eio_job_file_ls(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_ls(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path) { Eina_Promise_Owner* promise = eina_promise_add(); @@ -395,8 +402,8 @@ _file_stat_done_cb(void *data, Eio_File *handle EINA_UNUSED, const Eina_Stat *st } static Eina_Promise* -_eio_job_file_direct_stat(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_direct_stat(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path) { Eina_Promise_Owner* promise = eina_promise_add(); @@ -422,8 +429,8 @@ _eio_job_file_direct_stat(Eo *obj, /* eXtended attribute manipulation */ static Eina_Promise* -_eio_job_file_xattr_list_get(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_xattr_list_get(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path) { Eina_Promise_Owner *promise = eina_promise_add(); @@ -449,8 +456,8 @@ _eio_job_file_xattr_list_get(Eo *obj, } static Eina_Promise* -_eio_job_file_xattr_set(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_xattr_set(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path, const char *attribute, const char *xattr_data, @@ -483,8 +490,8 @@ _eio_job_file_xattr_set(Eo *obj, } static Eina_Promise* -_eio_job_file_xattr_get(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_xattr_get(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path, const char *attribute) { @@ -521,8 +528,8 @@ _file_open_open_cb(void *data, Eio_File *handler EINA_UNUSED, Eina_File *file) } static Eina_Promise* -_eio_job_file_open(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_open(Eo *obj, + Efl_Io_Manager_Data *pd, const char *path, Eina_Bool shared) { @@ -555,8 +562,8 @@ _file_close_done_cb(void *data, Eio_File *handler EINA_UNUSED) } static void -_eio_job_file_close(Eo *obj, - Eio_Job_Data *pd, +_efl_io_manager_file_close(Eo *obj, + Efl_Io_Manager_Data *pd, Eina_File *file, Eina_Promise_Owner *promise) { @@ -573,9 +580,9 @@ _eio_job_file_close(Eo *obj, } static Eo_Base* -_eio_job_eo_base_constructor(Eo *obj, Eio_Job_Data *pd EINA_UNUSED) +_efl_io_manager_eo_base_constructor(Eo *obj, Efl_Io_Manager_Data *pd EINA_UNUSED) { - obj = eo_constructor(eo_super(obj, EIO_JOB_CLASS)); + obj = eo_constructor(eo_super(obj, EFL_IO_MANAGER_CLASS)); pd->object = obj; pd->operations = NULL; @@ -584,9 +591,11 @@ _eio_job_eo_base_constructor(Eo *obj, Eio_Job_Data *pd EINA_UNUSED) } static void -_eio_job_eo_base_destructor(Eo *obj, Eio_Job_Data *pd EINA_UNUSED) +_efl_io_manager_eo_base_destructor(Eo *obj, Efl_Io_Manager_Data *pd EINA_UNUSED) { - eo_destructor(eo_super(obj, EIO_JOB_CLASS)); + eo_destructor(eo_super(obj, EFL_IO_MANAGER_CLASS)); + + // FIXME: cancel all pending promise } -#include "eio_job.eo.c" +#include "efl_io_manager.eo.c" diff --git a/src/lib/eio/eio_job.eo b/src/lib/eio/efl_io_manager.eo index c7fa877f5d..a89f59dd9b 100644 --- a/src/lib/eio/eio_job.eo +++ b/src/lib/eio/efl_io_manager.eo @@ -7,6 +7,8 @@ struct Eio.Data size: uint; } +// FIXME: all events should be Eo objects not data if we want to modify them + struct Eio.Filter.Direct.Data { info: const(Eina.File.Direct.Info)*; @@ -25,7 +27,9 @@ struct Eio.Xattr.Data size: uint; } -class Eio.Job (Eo.Base) +// FIXME: We should send list of stuff in progress not single item, callback cost is to high + +class Efl.Io.Manager (Eo.Base) { [[Class representing an asynchronous file operation.]] diff --git a/src/lib/eio/eio_job_private.h b/src/lib/eio/eio_job_private.h deleted file mode 100644 index 26a2a5a9b6..0000000000 --- a/src/lib/eio/eio_job_private.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _EIO_FILE_PRIVATE_H -#define _EIO_FILE_PRIVATE_H - -typedef struct _Eio_Job_Data Eio_Job_Data; - -struct _Eio_Job_Data -{ - Eo *object; - Eina_List *operations; -}; - -#endif diff --git a/src/tests/eio/eio_test_job.c b/src/tests/eio/eio_test_manager.c index 0a532ebf7d..80ac58db3b 100644 --- a/src/tests/eio/eio_test_job.c +++ b/src/tests/eio/eio_test_manager.c @@ -101,10 +101,10 @@ _stat_done_cb(void *data, void *value) ecore_main_loop_quit(); } -typedef Eina_Promise* (*Eio_Job_Test_Stat_Ls_Func)(Eo *job, const char *path); +typedef Eina_Promise* (*Efl_Io_Manager_Test_Stat_Ls_Func)(Eo *job, const char *path); static void -_do_ls_test(Eio_Job_Test_Stat_Ls_Func ls_func, +_do_ls_test(Efl_Io_Manager_Test_Stat_Ls_Func ls_func, const Eo_Event_Description *event, Eo_Event_Cb filter_cb, Eina_Promise_Progress_Cb progress_cb, @@ -113,7 +113,7 @@ _do_ls_test(Eio_Job_Test_Stat_Ls_Func ls_func, { int main_files = 0; - Eio_Job *job = eo_add(EIO_JOB_CLASS, NULL); + Efl_Io_Manager *job = eo_add(EFL_IO_MANAGER_CLASS, NULL); Eina_Promise *promise = NULL; eo_event_callback_add(job, event, filter_cb, NULL); @@ -130,19 +130,19 @@ _do_ls_test(Eio_Job_Test_Stat_Ls_Func ls_func, } static void -_do_direct_ls_test(Eio_Job_Test_Stat_Ls_Func ls_func, +_do_direct_ls_test(Efl_Io_Manager_Test_Stat_Ls_Func ls_func, int expected_test_count, const char *test_dirname) { _do_ls_test(ls_func, - EIO_JOB_EVENT_FILTER_DIRECT, + EFL_IO_MANAGER_EVENT_FILTER_DIRECT, (Eo_Event_Cb)&_filter_direct_cb, (Eina_Promise_Progress_Cb)&_main_direct_cb, expected_test_count, test_dirname); } -START_TEST(eio_job_test_file_direct_stat) +START_TEST(efl_io_manager_test_file_direct_stat) { Eina_Bool is_dir; int ret; @@ -160,17 +160,17 @@ START_TEST(eio_job_test_file_direct_stat) Eina_Tmpstr *nested_dirname = create_test_dirs(test_dirname); Eina_Tmpstr *nested_filename = get_full_path(test_dirname, files[3]); - Eio_Job *job = eo_add(EIO_JOB_CLASS, NULL); + Efl_Io_Manager *job = eo_add(EFL_IO_MANAGER_CLASS, NULL); Eina_Promise *promise = NULL; // Start testing is_dir = EINA_TRUE; - promise = eio_job_file_direct_stat(job, nested_dirname); + promise = efl_io_manager_file_direct_stat(job, nested_dirname); eina_promise_then(promise, &_stat_done_cb, &_error_cb, &is_dir); ecore_main_loop_begin(); is_dir = EINA_FALSE; - promise = eio_job_file_direct_stat(job, nested_filename); + promise = efl_io_manager_file_direct_stat(job, nested_filename); eina_promise_then(promise, &_stat_done_cb, &_error_cb, &is_dir); ecore_main_loop_begin(); eo_unref(job); @@ -188,7 +188,7 @@ START_TEST(eio_job_test_file_direct_stat) } END_TEST -START_TEST(eio_job_test_ls_funcs) +START_TEST(efl_io_manager_test_ls_funcs) { int ret; @@ -207,20 +207,20 @@ START_TEST(eio_job_test_ls_funcs) // Start testing - _do_ls_test(&eio_job_file_ls, - EIO_JOB_EVENT_FILTER_NAME, + _do_ls_test(&efl_io_manager_file_ls, + EFL_IO_MANAGER_EVENT_FILTER_NAME, (Eo_Event_Cb)&_filter_cb, (Eina_Promise_Progress_Cb)&_main_cb, 5, test_dirname); - _do_direct_ls_test(&eio_job_file_stat_ls, 5, test_dirname); + _do_direct_ls_test(&efl_io_manager_file_stat_ls, 5, test_dirname); - _do_direct_ls_test(&eio_job_file_direct_ls, 5, test_dirname); + _do_direct_ls_test(&efl_io_manager_file_direct_ls, 5, test_dirname); - _do_direct_ls_test(&eio_job_dir_stat_ls, 8, test_dirname); + _do_direct_ls_test(&efl_io_manager_dir_stat_ls, 8, test_dirname); - _do_direct_ls_test(&eio_job_dir_direct_ls, 8, test_dirname); + _do_direct_ls_test(&efl_io_manager_dir_direct_ls, 8, test_dirname); // Cleanup fail_if(!ecore_file_recursive_rm(test_dirname)); @@ -235,7 +235,7 @@ START_TEST(eio_job_test_ls_funcs) } END_TEST -START_TEST(eio_job_test_open) +START_TEST(efl_io_manager_test_open) { Eina_Bool opened_file; int ret; @@ -254,10 +254,10 @@ START_TEST(eio_job_test_open) Eina_Tmpstr *nested_filename = get_full_path(test_dirname, files[3]); opened_file = EINA_FALSE; - Eio_Job *job = eo_add(EIO_JOB_CLASS, NULL); + Efl_Io_Manager *job = eo_add(EFL_IO_MANAGER_CLASS, NULL); Eina_Promise *promise = NULL; - promise = eio_job_file_open(job, nested_filename, EINA_FALSE); + promise = efl_io_manager_file_open(job, nested_filename, EINA_FALSE); eina_promise_then(promise, &_open_done_cb, &_error_cb, &opened_file); ecore_main_loop_begin(); eo_unref(job); @@ -268,7 +268,7 @@ START_TEST(eio_job_test_open) eina_tmpstr_del(nested_dirname); eina_tmpstr_del(test_dirname); - + eio_shutdown(); eina_tmpstr_del(nested_filename); ecore_file_shutdown(); @@ -280,8 +280,7 @@ END_TEST void eio_test_job(TCase *tc) { - tcase_add_test(tc, eio_job_test_ls_funcs); - tcase_add_test(tc, eio_job_test_file_direct_stat); - tcase_add_test(tc, eio_job_test_open); + tcase_add_test(tc, efl_io_manager_test_ls_funcs); + tcase_add_test(tc, efl_io_manager_test_file_direct_stat); + tcase_add_test(tc, efl_io_manager_test_open); } - diff --git a/src/tests/eio/eio_test_job_xattr.c b/src/tests/eio/eio_test_manager_xattr.c index 52a988a38a..94f5b49425 100644 --- a/src/tests/eio/eio_test_job_xattr.c +++ b/src/tests/eio/eio_test_manager_xattr.c @@ -129,7 +129,7 @@ START_TEST(eio_test_job_xattr_set) fprintf(stderr, "eio_test_job_xattr_set\n"); fflush(stderr); - job = eo_add(EIO_JOB_CLASS, NULL); + job = eo_add(EFL_IO_MANAGER_CLASS, NULL); test_file_path = get_full_path(XATTR_TEST_DIR, filename); fd = open(test_file_path, @@ -142,7 +142,7 @@ START_TEST(eio_test_job_xattr_set) for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i) { - attrib_promises[i] = eio_job_file_xattr_set + attrib_promises[i] = efl_io_manager_file_xattr_set (job, test_file_path, attribute[i], attr_data[i], strlen(attr_data[i]), EINA_XATTR_INSERT); @@ -163,7 +163,7 @@ START_TEST(eio_test_job_xattr_set) for (i = 0; i < sizeof(attribute) / sizeof(attribute[0]); ++i) { - attrib_promises[i] = eio_job_file_xattr_get(job, test_file_path, attribute[i]); + attrib_promises[i] = efl_io_manager_file_xattr_get(job, test_file_path, attribute[i]); } eina_promise_then(eina_promise_all(eina_carray_iterator_new((void**)attrib_promises)), @@ -173,8 +173,8 @@ START_TEST(eio_test_job_xattr_set) num_of_attr = 0; - eo_event_callback_add(job, EIO_JOB_EVENT_XATTR, _filter_cb, NULL); - list_promise = eio_job_file_xattr_list_get(job, test_file_path); + eo_event_callback_add(job, EFL_IO_MANAGER_EVENT_XATTR, _filter_cb, NULL); + list_promise = efl_io_manager_file_xattr_list_get(job, test_file_path); eina_promise_progress_cb_add(list_promise, _main_cb, &num_of_attr, NULL); eina_promise_then(list_promise, _done_cb, _error_cb, &num_of_attr); |