summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2018-01-19 15:25:23 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-04-30 14:21:12 -0700
commit51776fb94ac8cc01bc994374565baf1f09b544b8 (patch)
treee0ef21e91f33e83f9472293dab71922dd4118c9d /src/lib/eio
parentda45eb54a8b2e3ada63add491d1cf1278b882cdb (diff)
eio: convert efl_io_manager_direct_ls to Eina_Future.
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_manager.c52
-rw-r--r--src/lib/eio/efl_io_manager.eo3
2 files changed, 38 insertions, 17 deletions
diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c
index 82ec984060..4a638659a2 100644
--- a/src/lib/eio/efl_io_manager.c
+++ b/src/lib/eio/efl_io_manager.c
@@ -172,6 +172,23 @@ _future_string_cb(void *data EINA_UNUSED, Eio_File *handler, Eina_Array *gather)
172 172
173/* Direct listing callbacks */ 173/* Direct listing callbacks */
174static void 174static void
175_future_file_info_cb(void *data EINA_UNUSED, Eio_File *handler, Eina_Array *gather)
176{
177 EflIoDirectInfo info = ecore_thread_local_data_find(handler->thread, ".info");
178 void *info_data = ecore_thread_local_data_find(handler->thread, ".info_data");
179 Eio_File_Direct_Info *d;
180
181 if (!info) goto end;
182
183 info(info_data, gather);
184
185 end:
186 while ((d = eina_array_pop(gather)))
187 eio_direct_info_free(d);
188 eina_array_free(gather);
189}
190
191static void
175_file_info_cb(void *data, Eio_File *handler, Eina_Array *gather) 192_file_info_cb(void *data, Eio_File *handler, Eina_Array *gather)
176{ 193{
177 Efl_Promise *p = data; 194 Efl_Promise *p = data;
@@ -213,44 +230,47 @@ _file_info_cb(void *data, Eio_File *handler, Eina_Array *gather)
213} 230}
214 231
215/* Method implementations */ 232/* Method implementations */
216static Efl_Future * 233static Eina_Future *
217_efl_io_manager_direct_ls(Eo *obj, 234_efl_io_manager_direct_ls(Eo *obj,
218 Efl_Io_Manager_Data *pd EINA_UNUSED, 235 Efl_Io_Manager_Data *pd EINA_UNUSED,
219 const char *path, 236 const char *path,
220 Eina_Bool recursive) 237 Eina_Bool recursive,
238 void *info_data, EflIoDirectInfo info, Eina_Free_Cb info_free_cb)
221{ 239{
222 Efl_Promise *p; 240 Eina_Promise *p;
241 Eina_Future *future;
223 Eio_File *h; 242 Eio_File *h;
224 243
225 Eo *loop = efl_loop_get(obj); 244 p = efl_loop_promise_new(obj, _efl_io_manager_future_cancel, NULL);
226 p = efl_add(EFL_PROMISE_CLASS, loop);
227 if (!p) return NULL; 245 if (!p) return NULL;
246 future = eina_future_new(p);
228 247
229 if (!recursive) 248 if (!recursive)
230 { 249 {
231 h = _eio_file_direct_ls(path, 250 h = _eio_file_direct_ls(path,
232 _file_info_cb, 251 _future_file_info_cb,
233 _file_done_cb, 252 _future_file_done_cb,
234 _file_error_cb, 253 _future_file_error_cb,
235 p); 254 p);
236 } 255 }
237 else 256 else
238 { 257 {
239 h = _eio_dir_direct_ls(path, 258 h = _eio_dir_direct_ls(path,
240 _file_info_cb, 259 _future_file_info_cb,
241 _file_done_cb, 260 _future_file_done_cb,
242 _file_error_cb, 261 _future_file_error_cb,
243 p); 262 p);
244 } 263 }
245
246 if (!h) goto end; 264 if (!h) goto end;
247 265
248 efl_event_callback_array_add(p, promise_progress_handling(), h); 266 ecore_thread_local_data_add(h->thread, ".info", info, NULL, EINA_TRUE);
249 return efl_promise_future_get(p); 267 ecore_thread_local_data_add(h->thread, ".info_data", info_data, info_free_cb, EINA_TRUE);
268 eina_promise_data_set(p, h);
269
270 return efl_future_Eina_FutureXXX_then(obj, future);
250 271
251 end: 272 end:
252 efl_del(p); 273 return future;
253 return NULL;
254} 274}
255 275
256static Efl_Future * 276static Efl_Future *
diff --git a/src/lib/eio/efl_io_manager.eo b/src/lib/eio/efl_io_manager.eo
index 1835cd6598..ef10cabbe4 100644
--- a/src/lib/eio/efl_io_manager.eo
+++ b/src/lib/eio/efl_io_manager.eo
@@ -42,8 +42,9 @@ class Efl.Io.Manager (Efl.Loop_Consumer)
42 params { 42 params {
43 @in path: string;[[Path we want to list entries for]] 43 @in path: string;[[Path we want to list entries for]]
44 @in recursive: bool; [[If $true, list entries recursively, $false otherwise]] 44 @in recursive: bool; [[If $true, list entries recursively, $false otherwise]]
45 info: EflIoDirectInfo; [[Callback called for each packet of @Eina.File.Direct.Info]]
45 } 46 }
46 return: future<uint64, const(array<ptr(Eina.File.Direct.Info)>)>; [[List of entries in path]] 47 return: ptr(Eina.Future) @owned; [[Amount of files found during the listing of the directory]]
47 } 48 }
48 49
49 stat_ls { 50 stat_ls {