cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=03797a33ab6955671e6701fa65a3664aaade1d07

commit 03797a33ab6955671e6701fa65a3664aaade1d07
Author: Cedric Bail <ced...@osg.samsung.com>
Date:   Fri Sep 16 18:21:11 2016 -0700

    ecore,ecore_con: fix migration to efl_future.
    
    Efl_Future actually work with weak reference. So you do not need to
    set things to NULL, but you actually need to register the memory location
    of the future with efl_future_use.
---
 src/lib/ecore/efl_io_copier.c                | 14 +++-----------
 src/lib/ecore_con/efl_net_dialer_http.c      |  4 +---
 src/lib/ecore_con/efl_net_dialer_tcp.c       | 26 ++++++--------------------
 src/lib/ecore_con/efl_net_dialer_websocket.c | 16 +++++-----------
 4 files changed, 15 insertions(+), 45 deletions(-)

diff --git a/src/lib/ecore/efl_io_copier.c b/src/lib/ecore/efl_io_copier.c
index 8a44052..ad9a38a 100644
--- a/src/lib/ecore/efl_io_copier.c
+++ b/src/lib/ecore/efl_io_copier.c
@@ -73,8 +73,6 @@ _efl_io_copier_job(void *data, const Efl_Event *ev 
EINA_UNUSED)
    Eo *o = data;
    Efl_Io_Copier_Data *pd = efl_data_scope_get(o, MY_CLASS);
 
-   pd->job = NULL;
-
    _COPIER_DBG(o, pd);
    efl_ref(o);
 
@@ -104,7 +102,7 @@ _efl_io_copier_job_schedule(Eo *o, Efl_Io_Copier_Data *pd)
 {
    if (pd->job) return;
 
-   pd->job = efl_loop_job(efl_loop_user_loop_get(o), o);
+   efl_future_use(&pd->job, efl_loop_job(efl_loop_user_loop_get(o), o));
    efl_future_then(pd->job, _efl_io_copier_job, NULL, NULL, o);
 }
 
@@ -573,10 +571,7 @@ _efl_io_copier_efl_io_closer_close(Eo *o, 
Efl_Io_Copier_Data *pd)
    _COPIER_DBG(o, pd);
 
    if (pd->job)
-     {
-        efl_future_cancel(pd->job);
-        pd->job = NULL;
-     }
+     efl_future_cancel(pd->job);
 
    if (pd->source)
      {
@@ -696,10 +691,7 @@ _efl_io_copier_efl_object_destructor(Eo *o, 
Efl_Io_Copier_Data *pd)
    efl_io_copier_destination_set(o, NULL);
 
    if (pd->job)
-     {
-        efl_future_cancel(pd->job);
-        pd->job = NULL;
-     }
+     efl_future_cancel(pd->job);
 
    efl_destructor(efl_super(o, MY_CLASS));
 
diff --git a/src/lib/ecore_con/efl_net_dialer_http.c 
b/src/lib/ecore_con/efl_net_dialer_http.c
index 39a0fba..0a20112 100644
--- a/src/lib/ecore_con/efl_net_dialer_http.c
+++ b/src/lib/ecore_con/efl_net_dialer_http.c
@@ -1194,7 +1194,6 @@ _efl_net_dialer_http_efl_object_destructor(Eo *o, 
Efl_Net_Dialer_Http_Data *pd)
    else if (pd->pending_close)
      {
         efl_future_cancel(pd->pending_close);
-        pd->pending_close = NULL;
         efl_io_closer_close(o);
      }
    else if (efl_io_closer_close_on_destructor_get(o) &&
@@ -1555,7 +1554,7 @@ _efl_net_dialer_http_efl_io_closer_close(Eo *o, 
Efl_Net_Dialer_Http_Data *pd)
      {
         if (!pd->pending_close)
           {
-             pd->pending_close = efl_loop_job(efl_loop_user_loop_get(o), o);
+             efl_future_use(&pd->pending_close, 
efl_loop_job(efl_loop_user_loop_get(o), o));
              efl_future_then(pd->pending_close, 
_efl_net_dialer_http_pending_close, NULL, NULL, o);
              DBG("dialer=%p closed from CURL callback, schedule close job=%p", 
o, pd->pending_close);
           }
@@ -1593,7 +1592,6 @@ _efl_net_dialer_http_pending_close(void *data, const 
Efl_Event *ev EINA_UNUSED)
    Eo *o = data;
    Efl_Net_Dialer_Http_Data *pd = efl_data_scope_get(o, MY_CLASS);
 
-   pd->pending_close = NULL;
    _efl_net_dialer_http_efl_io_closer_close(o, pd);
 }
 
diff --git a/src/lib/ecore_con/efl_net_dialer_tcp.c 
b/src/lib/ecore_con/efl_net_dialer_tcp.c
index d9dd70c..a3c2e0b 100644
--- a/src/lib/ecore_con/efl_net_dialer_tcp.c
+++ b/src/lib/ecore_con/efl_net_dialer_tcp.c
@@ -66,10 +66,7 @@ _efl_net_dialer_tcp_efl_object_destructor(Eo *o, 
Efl_Net_Dialer_Tcp_Data *pd)
      efl_io_closer_close(o);
 
    if (pd->connect.timeout)
-     {
-        efl_future_cancel(pd->connect.timeout);
-        pd->connect.timeout = NULL;
-     }
+     efl_future_cancel(pd->connect.timeout);
 
    if (pd->connect.thread)
      {
@@ -209,8 +206,6 @@ _efl_net_dialer_tcp_connect_timeout(void *data, const 
Efl_Event *ev EINA_UNUSED)
    Efl_Net_Dialer_Tcp_Data *pd = efl_data_scope_get(o, MY_CLASS);
    Eina_Error err = ETIMEDOUT;
 
-   pd->connect.timeout = NULL;
-
    if (pd->resolve.thread)
      {
         ecore_thread_cancel(pd->resolve.thread);
@@ -285,13 +280,10 @@ _efl_net_dialer_tcp_efl_net_dialer_dial(Eo *o, 
Efl_Net_Dialer_Tcp_Data *pd EINA_
    efl_net_dialer_address_dial_set(o, address);
 
    if (pd->connect.timeout)
-     {
-        efl_future_cancel(pd->connect.timeout);
-        pd->connect.timeout = NULL;
-     }
+     efl_future_cancel(pd->connect.timeout);
    if (pd->timeout_dial > 0.0)
      {
-        pd->connect.timeout = efl_loop_timeout(efl_loop_user_loop_get(o), 
pd->timeout_dial, o);
+        efl_future_use(&pd->connect.timeout, 
efl_loop_timeout(efl_loop_user_loop_get(o), pd->timeout_dial, o));
         efl_future_then(pd->connect.timeout, 
_efl_net_dialer_tcp_connect_timeout, NULL, NULL, o);
      }
 
@@ -328,13 +320,10 @@ _efl_net_dialer_tcp_efl_net_dialer_timeout_dial_set(Eo *o 
EINA_UNUSED, Efl_Net_D
 {
    pd->timeout_dial = seconds;
    if (pd->connect.timeout)
-     {
-        efl_future_cancel(pd->connect.timeout);
-        pd->connect.timeout = NULL;
-     }
+     efl_future_cancel(pd->connect.timeout);
    if (pd->timeout_dial > 0.0)
      {
-        pd->connect.timeout = efl_loop_timeout(efl_loop_user_loop_get(o), 
pd->timeout_dial, o);
+        efl_future_use(&pd->connect.timeout, 
efl_loop_timeout(efl_loop_user_loop_get(o), pd->timeout_dial, o));
         efl_future_then(pd->connect.timeout, 
_efl_net_dialer_tcp_connect_timeout, NULL, NULL, o);
      }
 }
@@ -349,10 +338,7 @@ EOLIAN static void
 _efl_net_dialer_tcp_efl_net_dialer_connected_set(Eo *o, 
Efl_Net_Dialer_Tcp_Data *pd, Eina_Bool connected)
 {
    if (pd->connect.timeout)
-     {
-        efl_future_cancel(pd->connect.timeout);
-        pd->connect.timeout = NULL;
-     }
+     efl_future_cancel(pd->connect.timeout);
    if (pd->connected == connected) return;
    pd->connected = connected;
    if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, 
NULL);
diff --git a/src/lib/ecore_con/efl_net_dialer_websocket.c 
b/src/lib/ecore_con/efl_net_dialer_websocket.c
index 8483730..613181e 100644
--- a/src/lib/ecore_con/efl_net_dialer_websocket.c
+++ b/src/lib/ecore_con/efl_net_dialer_websocket.c
@@ -544,10 +544,7 @@ _efl_net_dialer_websocket_job_dispatch_frame(Eo *o, 
Efl_Net_Dialer_Websocket_Dat
            else
              efl_event_callback_call(o, EFL_IO_CLOSER_EVENT_CLOSED, NULL);
            if (pd->close_timeout)
-             {
-                efl_future_cancel(pd->close_timeout);
-                pd->close_timeout = NULL;
-             }
+             efl_future_cancel(pd->close_timeout);
            break;
         }
 
@@ -768,7 +765,7 @@ _efl_net_dialer_websocket_job_schedule(Eo *o, 
Efl_Net_Dialer_Websocket_Data *pd)
 
    loop = efl_loop_user_loop_get(o);
    if (!loop) return;
-   pd->job = efl_loop_job(loop, o);
+   efl_future_use(&pd->job, efl_loop_job(loop, o));
    efl_future_then(pd->job, _efl_net_dialer_websocket_job, NULL, NULL, o);
 }
 
@@ -964,11 +961,9 @@ _efl_net_dialer_websocket_efl_object_destructor(Eo *o, 
Efl_Net_Dialer_Websocket_
    Eina_Stringshare *str;
 
    efl_event_callback_array_del(pd->http, 
_efl_net_dialer_websocket_http_cbs(), o);
+
    if (pd->close_timeout)
-     {
-        efl_future_cancel(pd->close_timeout);
-        pd->close_timeout = NULL;
-     }
+     efl_future_cancel(pd->close_timeout);
 
    efl_del(pd->http);
    pd->http = NULL;
@@ -1500,7 +1495,6 @@ _efl_net_dialer_websocket_close_request_timeout(void 
*data, const Efl_Event *ev
    Eo *o = data;
    Efl_Net_Dialer_Websocket_Data *pd = efl_data_scope_get(o, MY_CLASS);
 
-   pd->close_timeout = NULL;
    DBG("server did not close the TCP socket, timeout");
    efl_event_callback_call(o, EFL_IO_CLOSER_EVENT_CLOSED, NULL);
 }
@@ -1516,7 +1510,7 @@ _efl_net_dialer_websocket_close_request(Eo *o, 
Efl_Net_Dialer_Websocket_Data *pd
    if (pd->close_timeout)
      efl_future_cancel(pd->close_timeout);
 
-   pd->close_timeout = efl_loop_timeout(efl_loop_user_loop_get(o), 2.0, o);
+   efl_future_use(&pd->close_timeout, 
efl_loop_timeout(efl_loop_user_loop_get(o), 2.0, o));
    efl_future_then(pd->close_timeout, 
_efl_net_dialer_websocket_close_request_timeout, NULL, NULL, o);
 
    efl_io_writer_can_write_set(o, EINA_FALSE);

-- 


Reply via email to