summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_promise.c
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-03 16:52:03 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-03 17:22:12 -0300
commit8fec0d5139a3ff30037ba159bb62ff2f733d96a8 (patch)
tree0316d756b8150e9ef40d76668e5084fdb06af29a /src/tests/ecore/ecore_test_promise.c
parent1dcccfdf8160ca6113d66c51c226302221b9a049 (diff)
eina: Remove unnecessary indirection to promises
Now when dealing with pointer types, we will not get pointer to pointer semantics in callbacks and eina_promise_owner_value_set for Eina_Promise. It will work as expected: Eina_Promise_Owner* promise = eina_promise_add(); void* p = malloc(sizeof(T)); eina_promise_owner_value_set(promise, p, &free);
Diffstat (limited to 'src/tests/ecore/ecore_test_promise.c')
-rw-r--r--src/tests/ecore/ecore_test_promise.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/tests/ecore/ecore_test_promise.c b/src/tests/ecore/ecore_test_promise.c
index decd5c9..f016580 100644
--- a/src/tests/ecore/ecore_test_promise.c
+++ b/src/tests/ecore/ecore_test_promise.c
@@ -22,7 +22,7 @@ START_TEST(ecore_test_promise)
22 22
23 ecore_init(); 23 ecore_init();
24 24
25 ecore_thread_promise_run(&promised_thread, NULL, NULL, 0, &promise); 25 ecore_thread_promise_run(&promised_thread, NULL, NULL, &promise);
26 eina_promise_then(promise, &promise_callback, NULL, NULL); 26 eina_promise_then(promise, &promise_callback, NULL, NULL);
27 27
28 ecore_main_loop_begin(); 28 ecore_main_loop_begin();
@@ -48,7 +48,7 @@ START_TEST(ecore_test_promise_error)
48 48
49 ecore_init(); 49 ecore_init();
50 50
51 ecore_thread_promise_run(&promise_error_thread, NULL, NULL, 0, &promise); 51 ecore_thread_promise_run(&promise_error_thread, NULL, NULL, &promise);
52 eina_promise_then(promise, NULL, &promise_error_callback, NULL); 52 eina_promise_then(promise, NULL, &promise_error_callback, NULL);
53 53
54 ecore_main_loop_begin(); 54 ecore_main_loop_begin();
@@ -64,7 +64,7 @@ START_TEST(ecore_test_promise_all)
64 64
65 ecore_init(); 65 ecore_init();
66 66
67 ecore_thread_promise_run(&promised_thread, NULL, NULL, 0, &first[0]); 67 ecore_thread_promise_run(&promised_thread, NULL, NULL, &first[0]);
68 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0])); 68 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0]));
69 eina_promise_then(promise, &promise_callback, NULL, NULL); 69 eina_promise_then(promise, &promise_callback, NULL, NULL);
70 70
@@ -89,7 +89,7 @@ START_TEST(ecore_test_promise_all_then_then)
89 89
90 int i = 0; 90 int i = 0;
91 91
92 ecore_thread_promise_run(&promised_thread, NULL, NULL, 0, &first[0]); 92 ecore_thread_promise_run(&promised_thread, NULL, NULL, &first[0]);
93 eina_promise_then(first[0], &promise_callback2, NULL, &i); 93 eina_promise_then(first[0], &promise_callback2, NULL, &i);
94 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0])); 94 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0]));
95 eina_promise_then(promise, &promise_callback2, NULL, &i); 95 eina_promise_then(promise, &promise_callback2, NULL, &i);
@@ -126,7 +126,7 @@ static void _ecore_test_promise_then_after_thread_finished_main_cb()
126 eina_lock_new(&data.lock); 126 eina_lock_new(&data.lock);
127 eina_condition_new(&data.cond, &data.lock); 127 eina_condition_new(&data.cond, &data.lock);
128 128
129 thread = ecore_thread_promise_run((Ecore_Thread_Promise_Cb)&promised_exit_thread, NULL, &data, 0, &promise); 129 thread = ecore_thread_promise_run((Ecore_Thread_Promise_Cb)&promised_exit_thread, NULL, &data, &promise);
130 130
131 eina_lock_take(&data.lock); 131 eina_lock_take(&data.lock);
132 while(!data.var) 132 while(!data.var)
@@ -161,7 +161,7 @@ static void _ecore_test_promise_then_after_thread_finished_all_main_cb()
161 eina_lock_new(&data.lock); 161 eina_lock_new(&data.lock);
162 eina_condition_new(&data.cond, &data.lock); 162 eina_condition_new(&data.cond, &data.lock);
163 163
164 thread = ecore_thread_promise_run((Ecore_Thread_Promise_Cb)&promised_exit_thread, NULL, &data, 0, &first[0]); 164 thread = ecore_thread_promise_run((Ecore_Thread_Promise_Cb)&promised_exit_thread, NULL, &data, &first[0]);
165 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0])); 165 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0]));
166 166
167 eina_lock_take(&data.lock); 167 eina_lock_take(&data.lock);
@@ -186,19 +186,19 @@ START_TEST(ecore_test_promise_then_after_thread_finished_all)
186} 186}
187END_TEST 187END_TEST
188 188
189void promised_block_thread(const void* data EINA_UNUSED, Eina_Promise_Owner* promise, Ecore_Thread* thread EINA_UNUSED) 189/* void promised_block_thread(const void* data EINA_UNUSED, Eina_Promise_Owner* promise, Ecore_Thread* thread EINA_UNUSED) */
190{ 190/* { */
191 struct timespec v = {.tv_sec = 1, .tv_nsec = 0}, rem; 191/* struct timespec v = {.tv_sec = 1, .tv_nsec = 0}, rem; */
192 if(nanosleep(&v, &rem) == -1 && errno == EINTR) 192/* if(nanosleep(&v, &rem) == -1 && errno == EINTR) */
193 do 193/* do */
194 { 194/* { */
195 v = rem; 195/* v = rem; */
196 } 196/* } */
197 while(nanosleep(&v, &rem) == -1 && errno == EINTR); 197/* while(nanosleep(&v, &rem) == -1 && errno == EINTR); */
198 198
199 int r = 10; 199/* int r = 10; */
200 eina_promise_owner_value_set(promise, &r, NULL); 200/* eina_promise_owner_value_set(promise, &r, NULL); */
201} 201/* } */
202 202
203static void 203static void
204_ecore_test_promise_normal_lifetime_cb(void* data EINA_UNUSED, void* value EINA_UNUSED, Eina_Promise* promise EINA_UNUSED) 204_ecore_test_promise_normal_lifetime_cb(void* data EINA_UNUSED, void* value EINA_UNUSED, Eina_Promise* promise EINA_UNUSED)
@@ -219,7 +219,7 @@ START_TEST(ecore_test_promise_normal_lifetime)
219 219
220 ecore_init(); 220 ecore_init();
221 221
222 promise_owner = eina_promise_default_add(0); 222 promise_owner = eina_promise_value_add(0);
223 223
224 promise = eina_promise_owner_promise_get(promise_owner); 224 promise = eina_promise_owner_promise_get(promise_owner);
225 225
@@ -240,7 +240,7 @@ START_TEST(ecore_test_promise_normal_lifetime_all)
240 240
241 ecore_init(); 241 ecore_init();
242 242
243 promise_owner = eina_promise_default_add(0); 243 promise_owner = eina_promise_value_add(0);
244 first[0] = eina_promise_owner_promise_get(promise_owner); 244 first[0] = eina_promise_owner_promise_get(promise_owner);
245 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0])); 245 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0]));
246 246
@@ -266,7 +266,7 @@ START_TEST(ecore_test_promise_immediate_set_lifetime)
266 266
267 ecore_init(); 267 ecore_init();
268 268
269 owner = eina_promise_default_add(0); 269 owner = eina_promise_value_add(0);
270 promise = eina_promise_owner_promise_get(owner); 270 promise = eina_promise_owner_promise_get(owner);
271 271
272 eina_promise_owner_value_set(owner, NULL, NULL); 272 eina_promise_owner_value_set(owner, NULL, NULL);
@@ -286,7 +286,7 @@ START_TEST(ecore_test_promise_immediate_set_lifetime_all)
286 286
287 ecore_init(); 287 ecore_init();
288 288
289 owner = eina_promise_default_add(0); 289 owner = eina_promise_value_add(0);
290 first[0] = eina_promise_owner_promise_get(owner); 290 first[0] = eina_promise_owner_promise_get(owner);
291 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0])); 291 promise = eina_promise_all(eina_carray_iterator_new((void**)&first[0]));
292 292
@@ -343,7 +343,7 @@ START_TEST(ecore_test_promise_cancel_promise)
343 eina_lock_new(&v.lock); 343 eina_lock_new(&v.lock);
344 eina_condition_new(&v.condvar, &v.lock); 344 eina_condition_new(&v.condvar, &v.lock);
345 345
346 ecore_thread_promise_run(&promise_cancel_thread, &_cancel_callback, &v, 0, &promise); 346 ecore_thread_promise_run(&promise_cancel_thread, &_cancel_callback, &v, &promise);
347 eina_promise_then(promise, NULL, &_cancel_promise_callback, NULL); 347 eina_promise_then(promise, NULL, &_cancel_promise_callback, NULL);
348 348
349 eina_promise_cancel(promise); 349 eina_promise_cancel(promise);
@@ -376,7 +376,7 @@ START_TEST(ecore_test_promise_progress_promise)
376 376
377 ecore_init(); 377 ecore_init();
378 378
379 ecore_thread_promise_run(&promise_progress_thread, NULL, NULL, 0, &promise); 379 ecore_thread_promise_run(&promise_progress_thread, NULL, NULL, &promise);
380 380
381 eina_promise_progress_cb_add(promise, &_progress_callback, NULL, NULL); 381 eina_promise_progress_cb_add(promise, &_progress_callback, NULL, NULL);
382 382