summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-09-13 15:52:40 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-09-13 15:53:00 -0700
commitb9ef9af74a4cc401c02468f20a68659b9b2a1235 (patch)
tree09740386a9da902389c689d0b96524bf09dd3d73 /src/lib/eio
parentba34b998eb6920fe0dbccd1037e8344c028754ec (diff)
eio: migrate efl.io.manager.open to use Eina_Future.
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_manager.c36
-rw-r--r--src/lib/eio/efl_io_manager.eo2
2 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c
index 75fa2289b0..0b7fb3def9 100644
--- a/src/lib/eio/efl_io_manager.c
+++ b/src/lib/eio/efl_io_manager.c
@@ -519,43 +519,43 @@ _efl_io_manager_xattr_get(Eo *obj,
519} 519}
520 520
521static void 521static void
522_file_open_cb(void *data, Eio_File *handler, Eina_File *file) 522_future_file_open_cb(void *data, Eio_File *handler EINA_UNUSED, Eina_File *file)
523{ 523{
524 Efl_Promise *p = data; 524 Eina_Promise *p = data;
525 525 Eina_Value v = EINA_VALUE_EMPTY;
526 efl_event_callback_array_del(p, promise_handling(), handler);
527
528 efl_promise_value_set(p, eina_file_dup(file), EINA_FREE_CB(eina_file_close));
529 526
530 efl_del(p); 527 eina_value_setup(&v, EINA_VALUE_TYPE_FILE);
528 eina_value_set(&v, file);
529 eina_promise_resolve(p, v);
530 eina_value_flush(&v);
531} 531}
532 532
533static Efl_Future * 533static Eina_Future *
534_efl_io_manager_open(Eo *obj, 534_efl_io_manager_open(Eo *obj,
535 Efl_Io_Manager_Data *pd EINA_UNUSED, 535 Efl_Io_Manager_Data *pd EINA_UNUSED,
536 const char *path, 536 const char *path,
537 Eina_Bool shared) 537 Eina_Bool shared)
538{ 538{
539 Efl_Promise *p; 539 Eina_Promise *p;
540 Eina_Future *future;
540 Eio_File *h; 541 Eio_File *h;
541 542
542 Eo *loop = efl_loop_get(obj); 543 p = eina_promise_new(efl_loop_future_scheduler_get(obj),
543 p = efl_add(EFL_PROMISE_CLASS, loop); 544 _efl_io_manager_future_cancel, NULL);
544 if (!p) return NULL; 545 if (!p) return NULL;
546 future = eina_future_new(p);
545 547
546 h = eio_file_open(path, shared, 548 h = eio_file_open(path, shared,
547 _file_open_cb, 549 _future_file_open_cb,
548 _file_error_cb, 550 _future_file_error_cb,
549 p); 551 p);
550
551 if (!h) goto end; 552 if (!h) goto end;
553 eina_promise_data_set(p, h);
552 554
553 efl_event_callback_array_add(p, promise_handling(), h); 555 return efl_future_Eina_FutureXXX_then(obj, future);
554 return efl_promise_future_get(p);
555 556
556 end: 557 end:
557 efl_del(p); 558 return future;
558 return NULL;
559} 559}
560 560
561static Eina_Future * 561static Eina_Future *
diff --git a/src/lib/eio/efl_io_manager.eo b/src/lib/eio/efl_io_manager.eo
index a4e8aaddc5..b1b5d85806 100644
--- a/src/lib/eio/efl_io_manager.eo
+++ b/src/lib/eio/efl_io_manager.eo
@@ -83,7 +83,7 @@ class Efl.Io.Manager (Efl.Loop_User)
83 @in path: string; [[Path to file]] 83 @in path: string; [[Path to file]]
84 @in shared: bool; [[$true if the file can be accessed by others, $false otherwise]] 84 @in shared: bool; [[$true if the file can be accessed by others, $false otherwise]]
85 } 85 }
86 return: future<Eina.File>; [[Eina file handle]] 86 return: own(ptr(Eina.Future)); [[Eina file handle]]
87 } 87 }
88 close { 88 close {
89 [[Closes an open Eina.File.]] 89 [[Closes an open Eina.File.]]