summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-01-04 16:06:05 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-01-16 14:33:20 -0800
commitb3d04f72008f26a3d847239db5e017a990502244 (patch)
treed28929950121290799e849ac51fbce28aae09569 /src/lib/eina
parentd67a7df9caadca59536e487f7d4fc6df1b33d8b7 (diff)
Revert "eina: add a function to free Eina_Promise attached data when the promise is destroyed."
A better solution is to actually have no eina_promise_data_set/get at all. This reverts commit ce56f32270c2f75adab022b701d3bdcbbbc3fb44. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D7574
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_promise.c21
-rw-r--r--src/lib/eina/eina_promise.h8
2 files changed, 3 insertions, 26 deletions
diff --git a/src/lib/eina/eina_promise.c b/src/lib/eina/eina_promise.c
index c239ba6261..222f7d5613 100644
--- a/src/lib/eina/eina_promise.c
+++ b/src/lib/eina/eina_promise.c
@@ -103,7 +103,6 @@ struct _Eina_Promise {
103 Eina_Future *future; 103 Eina_Future *future;
104 Eina_Future_Scheduler *scheduler; 104 Eina_Future_Scheduler *scheduler;
105 Eina_Promise_Cancel_Cb cancel; 105 Eina_Promise_Cancel_Cb cancel;
106 Eina_Free_Cb free_cb;
107 const void *data; 106 const void *data;
108}; 107};
109 108
@@ -307,19 +306,12 @@ _eina_promise_link(Eina_Promise *p, Eina_Future *f)
307} 306}
308 307
309static void 308static void
310_eina_promise_free(Eina_Promise *p)
311{
312 if (p->free_cb) p->free_cb((void*) p->data);
313 eina_mempool_free(_promise_mp, p);
314}
315
316static void
317_eina_promise_cancel(Eina_Promise *p) 309_eina_promise_cancel(Eina_Promise *p)
318{ 310{
319 DBG("Cancelling promise: %p, data: %p, future: %p", p, p->data, p->future); 311 DBG("Cancelling promise: %p, data: %p, future: %p", p, p->data, p->future);
320 _eina_promise_unlink(p); 312 _eina_promise_unlink(p);
321 p->cancel((void *)p->data, p); 313 p->cancel((void *)p->data, p);
322 _eina_promise_free(p); 314 eina_mempool_free(_promise_mp, p);
323} 315}
324 316
325static void 317static void
@@ -524,7 +516,7 @@ _eina_promise_deliver(Eina_Promise *p,
524 DBG("Promise %p has no future", p); 516 DBG("Promise %p has no future", p);
525 eina_value_flush(&value); 517 eina_value_flush(&value);
526 } 518 }
527 _eina_promise_free(p); 519 eina_mempool_free(_promise_mp, p);
528} 520}
529 521
530Eina_Bool 522Eina_Bool
@@ -643,7 +635,7 @@ _eina_promise_clean_dispatch(Eina_Promise *p, Eina_Value v)
643 // This function is called on a promise created with a scheduler, not a continue one. 635 // This function is called on a promise created with a scheduler, not a continue one.
644 _eina_future_dispatch(p->scheduler, f, v); 636 _eina_future_dispatch(p->scheduler, f, v);
645 } 637 }
646 _eina_promise_free(p); 638 eina_mempool_free(_promise_mp, p);
647} 639}
648 640
649static Eina_Value 641static Eina_Value
@@ -1119,13 +1111,6 @@ eina_promise_data_set(Eina_Promise *p,
1119 p->data = data; 1111 p->data = data;
1120} 1112}
1121 1113
1122EAPI void
1123eina_promise_data_free_cb_set(Eina_Promise *p,
1124 Eina_Free_Cb free_cb)
1125{
1126 EINA_SAFETY_ON_NULL_RETURN(p);
1127 p->free_cb = free_cb;
1128}
1129 1114
1130static Eina_Value 1115static Eina_Value
1131_eina_future_cb_easy(void *data, const Eina_Value value, 1116_eina_future_cb_easy(void *data, const Eina_Value value,
diff --git a/src/lib/eina/eina_promise.h b/src/lib/eina/eina_promise.h
index 1896260dba..14e550d866 100644
--- a/src/lib/eina/eina_promise.h
+++ b/src/lib/eina/eina_promise.h
@@ -629,14 +629,6 @@ EAPI void *eina_promise_data_get(const Eina_Promise *p) EINA_ARG_NONNULL(1);
629EAPI void eina_promise_data_set(Eina_Promise *p, void *data) EINA_ARG_NONNULL(1); 629EAPI void eina_promise_data_set(Eina_Promise *p, void *data) EINA_ARG_NONNULL(1);
630 630
631/** 631/**
632 * Sets the free callback used when the data attached on the promise is freed just before the destruction of the promise itself.
633 *
634 * @param[in] p The promise to set the free callback on.
635 * @param[in] free_cb The free callback.
636 */
637EAPI void eina_promise_data_free_cb_set(Eina_Promise *p, Eina_Free_Cb free_cb);
638
639/**
640 * Resolves a promise. 632 * Resolves a promise.
641 * 633 *
642 * This function schedules a resolve event in a 634 * This function schedules a resolve event in a