summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-09-11 16:10:46 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-09-11 16:10:46 -0700
commite33d0d99963f16038d33f8d95cf5427e2ed29390 (patch)
tree2374193c7e4538451a61777ea3712c152dff0936 /src/lib/eio
parentfa9acf8b356b4e6d5ae899770b64f98e1f1a67f0 (diff)
eio: first convertion to new future/promise.
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_manager.c51
-rw-r--r--src/lib/eio/efl_io_manager.eo2
2 files changed, 42 insertions, 11 deletions
diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c
index 51043f88c8..dc7b243ecf 100644
--- a/src/lib/eio/efl_io_manager.c
+++ b/src/lib/eio/efl_io_manager.c
@@ -434,7 +434,37 @@ _efl_io_manager_xattr_ls(Eo *obj,
434 return NULL; 434 return NULL;
435} 435}
436 436
437static Efl_Future * 437static void
438_future_file_done_cb(void *data, Eio_File *handler)
439{
440 Eina_Promise *p = data;
441 Eina_Value v = EINA_VALUE_EMPTY;
442
443 eina_value_setup(&v, EINA_VALUE_TYPE_UINT64);
444 eina_value_set(&v, handler->length);
445 eina_promise_resolve(p, v);
446}
447
448static void
449_future_file_error_cb(void *data,
450 Eio_File *handler EINA_UNUSED,
451 int error)
452{
453 Eina_Promise *p = data;
454 Eina_Value v = EINA_VALUE_EMPTY;
455
456 eina_value_setup(&v, EINA_VALUE_TYPE_ERROR);
457 eina_value_set(&v, error);
458 eina_promise_resolve(p, v);
459}
460
461static void
462_efl_io_manager_future_cancel(void *data, const Eina_Promise *dead_ptr EINA_UNUSED)
463{
464 eio_file_cancel(data);
465}
466
467static Eina_Future *
438_efl_io_manager_xattr_set(Eo *obj, 468_efl_io_manager_xattr_set(Eo *obj,
439 Efl_Io_Manager_Data *pd EINA_UNUSED, 469 Efl_Io_Manager_Data *pd EINA_UNUSED,
440 const char *path, 470 const char *path,
@@ -442,28 +472,29 @@ _efl_io_manager_xattr_set(Eo *obj,
442 Eina_Binbuf *data, 472 Eina_Binbuf *data,
443 Eina_Xattr_Flags flags) 473 Eina_Xattr_Flags flags)
444{ 474{
445 Efl_Promise *p; 475 Eina_Promise *p;
476 Eina_Future *future;
446 Eio_File *h; 477 Eio_File *h;
447 478
448 Eo *loop = efl_loop_get(obj); 479 p = eina_promise_new(efl_loop_future_scheduler_get(obj),
449 p = efl_add(EFL_PROMISE_CLASS, loop); 480 _efl_io_manager_future_cancel, NULL);
450 if (!p) return NULL; 481 if (!p) return NULL;
482 future = eina_future_new(p);
451 483
452 h = eio_file_xattr_set(path, attribute, 484 h = eio_file_xattr_set(path, attribute,
453 (const char *) eina_binbuf_string_get(data), 485 (const char *) eina_binbuf_string_get(data),
454 eina_binbuf_length_get(data), 486 eina_binbuf_length_get(data),
455 flags, 487 flags,
456 _file_done_cb, 488 _future_file_done_cb,
457 _file_error_cb, 489 _future_file_error_cb,
458 p); 490 p);
459 if (!h) goto end; 491 if (!h) goto end;
492 eina_promise_data_set(p, h);
460 493
461 efl_event_callback_array_add(p, promise_handling(), h); 494 return efl_future_Eina_FutureXXX_then(obj, future);
462 return efl_promise_future_get(p);
463 495
464 end: 496 end:
465 efl_del(p); 497 return future;
466 return NULL;
467} 498}
468 499
469static Efl_Future * 500static Efl_Future *
diff --git a/src/lib/eio/efl_io_manager.eo b/src/lib/eio/efl_io_manager.eo
index 4e7961aacb..34e70d985c 100644
--- a/src/lib/eio/efl_io_manager.eo
+++ b/src/lib/eio/efl_io_manager.eo
@@ -63,7 +63,7 @@ class Efl.Io.Manager (Efl.Loop_User)
63 data: ptr(Eina.Binbuf); [[Data to set as information]] 63 data: ptr(Eina.Binbuf); [[Data to set as information]]
64 flags: Eina.Xattr.Flags; [[Extended attributes flags]] 64 flags: Eina.Xattr.Flags; [[Extended attributes flags]]
65 } 65 }
66 return: future<uint64>; [[Future for asynchronous set operation]] 66 return: own(ptr(Eina.Future)); [[Future for asynchronous set operation]]
67 } 67 }
68 get { 68 get {
69 return: future<Eina.Binbuf>; [[Information]] 69 return: future<Eina.Binbuf>; [[Information]]