Let's avoid to use uv_default_loop() whereever possible
hnakamur opened this issue · comments
Instead, let's use uv_loop_t* luv_get_loop(lua_State *L).
And this function should be renamed to lev_get_loop() and moved to src/lev_new_base.c
The reason for avoiding uv_default_loop() is we should prepare so that we can have multiple uv loops in the future.
How many instances of this are in code? Let's close this ASAP.
Here it is.
$ grep uv_default_loop src/*
src/lev_main.c: r = uv_spawn(uv_default_loop(), &lworker->process, options);
src/lev_main.c: loop = uv_default_loop();
src/lev_main.c: uv_timer_init(uv_default_loop(), &gc_timer);
src/lev_new_base.c: uv_default_loop()->data = L;
src/lev_new_core.c: assert(uv_default_loop()->ev == loop);
src/lev_new_core.c: struct ev_loop* loop = uv_default_loop()->ev;
src/lev_new_core.c: uv_update_time(uv_default_loop());
src/lev_new_core.c: double now = (double)uv_now(uv_default_loop());
src/lev_new_core.c: uv_err_t err = uv_last_error(uv_default_loop());
src/lev_new_core.c: uv_print_active_handles(uv_default_loop());
src/lev_new_core.c: uv_print_all_handles(uv_default_loop());
src/lev_new_dns.c: loop = uv_default_loop();
src/lev_new_pipe.c: loop = uv_default_loop();
src/lev_new_process.c: loop = uv_default_loop();
src/lev_new_tcp.c: loop = uv_default_loop();
src/lev_new_udp.c: loop = uv_default_loop();
Most of instances can be written as luv_get_loop(L).
src/lev_main.c should be fine with uv_default_loop() since we have not yet inited Lua, et cetera.
Thanks for merging.