summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-01-05 01:18:02 -0800
committerapache <apache@e5-web1.enlightenment.org>2018-01-05 01:18:02 -0800
commitff08e7f15b5296c2238cd2466a4b9fdeb9107f0a (patch)
tree7b18c4e8b7c940a746c8d1fed5a985b301c65e11 /pages
parentad9e45fa0c0b2d52eac38eece67434956d9ca9ff (diff)
Wiki page futures.md changed with summary [New loop policy] by Xavi Artigas
Diffstat (limited to 'pages')
-rw-r--r--pages/develop/guides/c/eina/futures.md.txt21
1 files changed, 8 insertions, 13 deletions
diff --git a/pages/develop/guides/c/eina/futures.md.txt b/pages/develop/guides/c/eina/futures.md.txt
index 4bbfd3c76..b9a231e71 100644
--- a/pages/develop/guides/c/eina/futures.md.txt
+++ b/pages/develop/guides/c/eina/futures.md.txt
@@ -38,29 +38,24 @@ The code returning the delayed value (the promise of a value) creates an ``Eina_
38 Eina_Promise *promise; 38 Eina_Promise *promise;
39 void *data; 39 void *data;
40 40
41 loop = efl_loop_main_get(EFL_LOOP_CLASS); 41 [...]
42 scheduler = efl_loop_future_scheduler_get(loop); 42 scheduler = efl_loop_future_scheduler_get(loop);
43 promise = eina_promise_new(scheduler, _promise_cancel_cb, data); 43 promise = eina_promise_new(scheduler, _promise_cancel_cb, data);
44``` 44```
45 45
46Most of the time you'll be using the *main loop* and its scheduler so you can cache the ``loop`` and ``scheduler`` variables from the above snippet in your code. There is no need to free them. 46Most of the time you'll be using the *application loop* you received in the ``efl_main()`` method of your application (see the [Main Loop Programming Guide](/develop/guides/c/core/main-loop.md)) and its scheduler so you can cache the ``loop`` and ``scheduler`` variables from the above snippet in your code. There is no need to free them.
47 47
48> **NOTE**: 48> **NOTE**:
49> You can also use ``efl_loop_promise_new()`` to simplify your code a bit: 49> You can also use ``efl_loop_promise_new()`` to simplify your code a bit:
50> ```c 50> ```c
51> loop = efl_loop_main_get(EFL_LOOP_CLASS);
52> promise = efl_loop_promise_new(loop, _promise_cancel_cb, data); 51> promise = efl_loop_promise_new(loop, _promise_cancel_cb, data);
53> ``` 52> ```
54> Or even simpler with ``efl_loop_main_promise_new()``:
55> ```c
56> promise = efl_loop_main_promise_new(_promise_cancel_cb, data);
57> ```
58 53
59You can attach arbitrary data to ``Eina_Promise``s which you can later retrieve with ``eina_promise_data_get()``. 54You can attach arbitrary data to ``Eina_Promise``s which you can later retrieve with ``eina_promise_data_get()``.
60 55
61Finally when creating ``Eina_Promise``s you should **always** provide a ``_cancel_callback`` as above, so you're notified if the promise is cancelled. This is chiefly because any pointer you might be keeping to the cancelled promise will be invalid after the callback but also because you have a chance to stop whatever process you had running to obtain the promised value. 56Finally when creating ``Eina_Promise``s you should **always** provide a ``_cancel_callback`` as above, so you're notified if the promise is cancelled. This is chiefly because any pointer you might be keeping to the cancelled promise will be invalid after the callback but also because you have a chance to stop whatever process you had running to obtain the promised value.
62 57
63See an example in [Test 1 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n93). 58See an example in [Test 1 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n91).
64 59
65## Creating a Future ## 60## Creating a Future ##
66 61
@@ -85,7 +80,7 @@ The ``success`` callback will be triggered when the promise is fulfilled and wil
85 80
86You can pass any data you want when registering callbacks. They will receive it through the ``data`` parameter. Use the ``free`` callback to free it since it will be called no matter what way the promise ends (successfully resolved or cancelled). 81You can pass any data you want when registering callbacks. They will receive it through the ``data`` parameter. Use the ``free`` callback to free it since it will be called no matter what way the promise ends (successfully resolved or cancelled).
87 82
88See an example in [Test 1 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n99). 83See an example in [Test 1 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n97).
89 84
90## Resolving a Promise ## 85## Resolving a Promise ##
91 86
@@ -103,7 +98,7 @@ Resolving a promise means delivering the promised value. This is done through an
103 98
104All the callback methods registered with this promise (through ``Eina_Future`` objects as seen above) will be called and the ``Eina_Value`` will be delivered to them. 99All the callback methods registered with this promise (through ``Eina_Future`` objects as seen above) will be called and the ``Eina_Value`` will be delivered to them.
105 100
106See an example in [Test 1 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n71). 101See an example in [Test 1 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n69).
107 102
108## Rejecting a Promise ## 103## Rejecting a Promise ##
109 104
@@ -119,7 +114,7 @@ Sometimes the code that delivers a promise can't fulfill it (think of a server r
119 114
120Instead of the ``success`` callback used in normal promise resolution, all ``Eina_Future`` objects registered to the rejected ``Eina_Promise`` will have their ``error`` callback triggered. Instead of the promised ``Eina_Value`` they'll receive the ``Eina_Error`` provided to ``eina_promise_reject()``. 115Instead of the ``success`` callback used in normal promise resolution, all ``Eina_Future`` objects registered to the rejected ``Eina_Promise`` will have their ``error`` callback triggered. Instead of the promised ``Eina_Value`` they'll receive the ``Eina_Error`` provided to ``eina_promise_reject()``.
121 116
122See an example in [Test 2 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n120). 117See an example in [Test 2 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n118).
123 118
124## Cancelling a Future ## 119## Cancelling a Future ##
125 120
@@ -147,7 +142,7 @@ Future cancellation is achieved through ``efl_future_cancel()``:
147 142
148In the above example, ``_promise_cancel_cb()`` will be called to notify the promise-fulfilling code that it has been cancelled. In addition to this ``_promise_error_cb()`` will be called to notify any code waiting on the promised value that it will never arrive (the reported error will be ``EINA_ERROR_FUTURE_CANCEL``). 143In the above example, ``_promise_cancel_cb()`` will be called to notify the promise-fulfilling code that it has been cancelled. In addition to this ``_promise_error_cb()`` will be called to notify any code waiting on the promised value that it will never arrive (the reported error will be ``EINA_ERROR_FUTURE_CANCEL``).
149 144
150See an example in [Test 3 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n198). 145See an example in [Test 3 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n196).
151 146
152## Chaining Futures ## 147## Chaining Futures ##
153 148
@@ -172,7 +167,7 @@ Note also how each callback can have different data passed to it.
172 167
173A rejection of the promise or the cancellation of any of the futures will cancel the whole chain. 168A rejection of the promise or the cancellation of any of the futures will cancel the whole chain.
174 169
175See an example in [Test 4 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n269). 170See an example in [Test 4 of eina_future.c](https://git.enlightenment.org/tools/examples.git/tree/reference/c/eina/src/eina_future.c#n265).
176 171
177## Callbacks and Easy Callbacks ## 172## Callbacks and Easy Callbacks ##
178 173