diff options
author | Vitor Sousa <vitorsousa@expertisesolutions.com.br> | 2019-05-23 18:41:57 +0000 |
---|---|---|
committer | Cedric BAIL <cedric.bail@free.fr> | 2019-05-29 15:53:23 -0700 |
commit | a86a0931f16f6a9d5afbff71364048dc859e2dff (patch) | |
tree | 9412183d21dab63fb55e9157c95187b1cb46e571 /src/lib/eo/eo.c | |
parent | 343698f7eceb7cc3cfdb21da955abd401adc16a8 (diff) | |
download | efl-a86a0931f16f6a9d5afbff71364048dc859e2dff.tar.gz |
eo: add events to track the ownership status of an Eo object
Some user code may want to track an object ownership in regard to whether it is
kept by just one owner or shared between many owners.
This is specially true for code provided by bindings to other programming
languages, where different kinds of resource management may take place.
The event `ownership,unique` is triggered whenever the object refcount goes
from two to one, as a signal that it has just one owner from now on.
The event `ownership,shared` is triggered whenever the object refcount goes
from one to two, as a signal that it has multiple owners from now on.
It will not trigger when further increasing the refcount to any value beyond
two.
We also add benchmarks for sharing (i.e. increasing the refcount) and them
unsharing objects, in order to evaluate the performance impact of this patch.
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D8678
Diffstat (limited to 'src/lib/eo/eo.c')
-rw-r--r-- | src/lib/eo/eo.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 0113434a8c..db96b24ef7 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1933,6 +1933,9 @@ efl_ref(const Eo *obj_id) ++(obj->user_refcount); if (EINA_UNLIKELY(obj->user_refcount == 1)) _efl_ref(obj); + else if (EINA_UNLIKELY(obj->ownership_track && obj->user_refcount == 2)) + efl_event_callback_call((Eo *) obj_id, EFL_EVENT_OWNERSHIP_SHARED, NULL); + #ifdef EO_DEBUG _eo_log_obj_ref_op(obj, EO_REF_OP_REF); #endif @@ -1991,6 +1994,10 @@ efl_unref(const Eo *obj_id) } _efl_unref(obj); } + else if (EINA_UNLIKELY(obj->ownership_track && obj->user_refcount == 1)) + { + efl_event_callback_call((Eo *) obj_id, EFL_EVENT_OWNERSHIP_UNIQUE, NULL); + } _apply_auto_unref(obj, obj_id); |