Remove efl_loop_main references, we should use our allocated loop
This commit is contained in:
parent
5c4053942e
commit
e9e0834b26
|
@ -122,10 +122,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
|
|||
version = efl_loop_efl_version_get(loop);
|
||||
printf("Running on EFL version %d.%d.%d [%s]\n\n", version->major, version->minor,
|
||||
version->micro, version->build_id);
|
||||
_print_loop(loop, "Current");
|
||||
|
||||
loop = efl_loop_main_get(loop);
|
||||
_print_loop(loop, "Application Main");
|
||||
_print_loop(loop, "Application");
|
||||
|
||||
loop = efl_add(EFL_LOOP_CONSUMER_CLASS, loop,
|
||||
efl_name_set(efl_added, "Loop Consumer"));
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
* the promise is resolved, passing a value among them.
|
||||
*/
|
||||
|
||||
static void _test1_simple_future();
|
||||
static void _test2_failed_future();
|
||||
static void _test3_cancelled_future();
|
||||
static void _test4_chained_future();
|
||||
static void _test1_simple_future(Efl_Loop *loop);
|
||||
static void _test2_failed_future(Efl_Loop *loop);
|
||||
static void _test3_cancelled_future(Efl_Loop *loop);
|
||||
static void _test4_chained_future(Efl_Loop *loop);
|
||||
|
||||
/* ----------------------- Generic helper methods ---------------------- */
|
||||
|
||||
|
@ -28,11 +28,10 @@ static void _test4_chained_future();
|
|||
* This simple method prints the content of a value and passes it on.
|
||||
*/
|
||||
static Eina_Value
|
||||
_value_print(void *data, const Eina_Value value)
|
||||
_value_print(void *data EINA_UNUSED, const Eina_Value value)
|
||||
{
|
||||
Eina_Promise *promise = (Eina_Promise *)data;
|
||||
char *str = eina_value_to_string(&value);
|
||||
printf(" Success callback: Promise %p resolved to '%s'\n", promise, str);
|
||||
printf(" Success callback: Promise resolved to '%s'\n", str);
|
||||
free(str);
|
||||
|
||||
return value;
|
||||
|
@ -53,8 +52,7 @@ _promise_cancel(void *data EINA_UNUSED, const Eina_Promise *dead EINA_UNUSED)
|
|||
static Eina_Value
|
||||
_error_print(void *data EINA_UNUSED, const Eina_Error error)
|
||||
{
|
||||
Eina_Promise *promise = (Eina_Promise *)data;
|
||||
printf(" Error callback: Promise %p encountered error '%s'\n", promise,
|
||||
printf(" Error callback: Promise encountered error '%s'\n",
|
||||
eina_error_msg_get(error));
|
||||
|
||||
return EINA_VALUE_EMPTY;
|
||||
|
@ -75,21 +73,21 @@ _test1_resolve(void *data, const Efl_Event *event)
|
|||
|
||||
/* Launches the next test */
|
||||
static void
|
||||
_test1_next_test(void *data EINA_UNUSED, const Eina_Future *dead_future EINA_UNUSED)
|
||||
_test1_next_test(void *data, const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
Efl_Loop *loop = data;
|
||||
|
||||
printf(" Test 1 finished\n");
|
||||
_test2_failed_future();
|
||||
_test2_failed_future(loop);
|
||||
}
|
||||
|
||||
/* TEST 1: Set up a promised future and resolve it from a timer callback */
|
||||
static void
|
||||
_test1_simple_future()
|
||||
_test1_simple_future(Efl_Loop *loop)
|
||||
{
|
||||
Efl_Loop *loop;
|
||||
Eina_Promise *promise;
|
||||
|
||||
// Create a promise
|
||||
loop = efl_loop_main_get(EFL_LOOP_CLASS);
|
||||
promise = eina_promise_new(efl_loop_future_scheduler_get(loop),
|
||||
_promise_cancel, NULL);
|
||||
printf("Test 1: Waiting for promise %p to be resolved...\n", promise);
|
||||
|
@ -99,7 +97,7 @@ _test1_simple_future()
|
|||
eina_future_then_easy(eina_future_new(promise),
|
||||
.success = _value_print,
|
||||
.free = _test1_next_test,
|
||||
.data = promise);
|
||||
.data = loop);
|
||||
|
||||
// Set up a regular timer that will trigger after 1s. We use it to
|
||||
// simulate a delayed promise resolve.
|
||||
|
@ -124,21 +122,21 @@ _test2_reject(void *data, const Efl_Event *event)
|
|||
|
||||
/* Launches the next test */
|
||||
static void
|
||||
_test2_next_test(void *data EINA_UNUSED, const Eina_Future *dead_future EINA_UNUSED)
|
||||
_test2_next_test(void *data, const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
Efl_Loop *loop = data;
|
||||
|
||||
printf(" Test 2 finished\n");
|
||||
_test3_cancelled_future();
|
||||
_test3_cancelled_future(loop);
|
||||
}
|
||||
|
||||
/* TEST 2: Set up a promised future and reject it from a timer callback */
|
||||
static void
|
||||
_test2_failed_future()
|
||||
_test2_failed_future(Efl_Loop *loop)
|
||||
{
|
||||
Efl_Loop *loop;
|
||||
Eina_Promise *promise;
|
||||
|
||||
// Create a promise
|
||||
loop = efl_loop_main_get(EFL_LOOP_CLASS);
|
||||
promise = eina_promise_new(efl_loop_future_scheduler_get(loop),
|
||||
_promise_cancel, NULL);
|
||||
printf("Test 2: Waiting for promise %p to be rejected...\n", promise);
|
||||
|
@ -150,7 +148,7 @@ _test2_failed_future()
|
|||
.success = _value_print,
|
||||
.error = _error_print,
|
||||
.free = _test2_next_test,
|
||||
.data = promise);
|
||||
.data = loop);
|
||||
|
||||
// Set up a regular timer that will trigger after 1s. We use it to
|
||||
// simulate a delayed promise rejection.
|
||||
|
@ -164,22 +162,22 @@ _test2_failed_future()
|
|||
|
||||
/* Launches the next test */
|
||||
static void
|
||||
_test3_next_test(void *data EINA_UNUSED, const Eina_Future *dead_future EINA_UNUSED)
|
||||
_test3_next_test(void *data, const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
Efl_Loop *loop = data;
|
||||
|
||||
printf(" Test 3 finished\n");
|
||||
_test4_chained_future();
|
||||
_test4_chained_future(loop);
|
||||
}
|
||||
|
||||
/* TEST 3: Set up a promised future and then cancel it */
|
||||
static void
|
||||
_test3_cancelled_future()
|
||||
_test3_cancelled_future(Efl_Loop *loop)
|
||||
{
|
||||
Efl_Loop *loop;
|
||||
Eina_Promise *promise;
|
||||
Eina_Future *future;
|
||||
|
||||
// Create a promise
|
||||
loop = efl_loop_main_get(EFL_LOOP_CLASS);
|
||||
promise = eina_promise_new(efl_loop_future_scheduler_get(loop),
|
||||
_promise_cancel, NULL);
|
||||
future = eina_future_new(promise);
|
||||
|
@ -192,7 +190,7 @@ _test3_cancelled_future()
|
|||
.success = _value_print,
|
||||
.error = _error_print,
|
||||
.free = _test3_next_test,
|
||||
.data = promise);
|
||||
.data = loop);
|
||||
|
||||
// Cancel the future before it has a chance to resolve
|
||||
eina_future_cancel(future);
|
||||
|
@ -251,13 +249,11 @@ _exit_cb(void *data EINA_UNUSED, const Eina_Value value EINA_UNUSED,
|
|||
* it on.
|
||||
*/
|
||||
static void
|
||||
_test4_chained_future(void)
|
||||
_test4_chained_future(Efl_Loop *loop)
|
||||
{
|
||||
Efl_Loop *loop;
|
||||
Eina_Promise *promise;
|
||||
|
||||
// Create a promise
|
||||
loop = efl_loop_main_get(EFL_LOOP_CLASS);
|
||||
promise = eina_promise_new(efl_loop_future_scheduler_get(loop),
|
||||
_promise_cancel, NULL);
|
||||
|
||||
|
@ -289,10 +285,12 @@ _test4_chained_future(void)
|
|||
/* ----------------------- Main ---------------------- */
|
||||
|
||||
EAPI_MAIN void
|
||||
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
||||
efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||
{
|
||||
Efl_Loop *loop = ev->object;
|
||||
|
||||
// Start the first test, the others will be launched when this one finishes
|
||||
_test1_simple_future();
|
||||
_test1_simple_future(loop);
|
||||
}
|
||||
|
||||
EFL_MAIN()
|
||||
|
|
|
@ -104,11 +104,13 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
|
|||
Eina_Bool require_online = EINA_FALSE;
|
||||
Efl_Net_Session_Technology technologies;
|
||||
Efl_Net_Session *session;
|
||||
Efl_Loop *loop;
|
||||
|
||||
loop = ev->object;
|
||||
// create a session that watches specifically for ethernet, wifi and bluetooth
|
||||
technologies = EFL_NET_SESSION_TECHNOLOGY_ETHERNET |
|
||||
EFL_NET_SESSION_TECHNOLOGY_WIFI | EFL_NET_SESSION_TECHNOLOGY_BLUETOOTH;
|
||||
session = efl_add(EFL_NET_SESSION_CLASS, efl_loop_main_get(EFL_LOOP_CLASS),
|
||||
session = efl_add(EFL_NET_SESSION_CLASS, loop,
|
||||
efl_name_set(efl_added, "Example Session"),
|
||||
// register the change callback for network state
|
||||
efl_event_callback_add(efl_added, EFL_NET_SESSION_EVENT_CHANGED,
|
||||
|
@ -130,7 +132,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
|
|||
printf("Use ^C (Control + C) to close it\n");
|
||||
|
||||
// Wait for 10 seconds before exiting this example
|
||||
efl_add(EFL_LOOP_TIMER_CLASS, ev->object,
|
||||
efl_add(EFL_LOOP_TIMER_CLASS, loop,
|
||||
efl_loop_timer_interval_set(efl_added, 10.0),
|
||||
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
|
||||
_quit_cb, NULL));
|
||||
|
|
Loading…
Reference in New Issue