Permalink
Browse files

unix, windows: rename uv_run2 to uv_run

This changes the prototype of uv_run() from:

  int uv_run(uv_loop_t* loop);

To:

  int uv_run(uv_loop_t* loop, uv_run_mode mode);

Where `mode` is UV_RUN_DEFAULT, UV_RUN_ONCE or UV_RUN_NOWAIT.

Fixes #683.
  • Loading branch information...
1 parent 4cbd5c7 commit 4ba03ddd569bdd361b1498d5f19ec0075db01500 @bnoordhuis bnoordhuis committed Jan 16, 2013
Showing with 214 additions and 230 deletions.
  1. +1 −7 include/uv.h
  2. +1 −6 src/unix/core.c
  3. +1 −6 src/win/core.c
  4. +1 −1 test/benchmark-async-pummel.c
  5. +2 −2 test/benchmark-async.c
  6. +2 −2 test/benchmark-fs-stat.c
  7. +1 −1 test/benchmark-getaddrinfo.c
  8. +2 −2 test/benchmark-loop-count.c
  9. +1 −1 test/benchmark-million-async.c
  10. +2 −2 test/benchmark-million-timers.c
  11. +5 −5 test/benchmark-multi-accept.c
  12. +1 −1 test/benchmark-ping-pongs.c
  13. +1 −1 test/benchmark-pound.c
  14. +4 −4 test/benchmark-pump.c
  15. +1 −1 test/benchmark-spawn.c
  16. +1 −1 test/benchmark-tcp-write-batch.c
  17. +1 −1 test/benchmark-udp-pummel.c
  18. +1 −1 test/blackhole-server.c
  19. +1 −1 test/dns-server.c
  20. +4 −4 test/echo-server.c
  21. +1 −1 test/test-active.c
  22. +1 −1 test/test-async.c
  23. +1 −1 test/test-callback-order.c
  24. +1 −1 test/test-callback-stack.c
  25. +1 −1 test/test-connection-fail.c
  26. +1 −1 test/test-delayed-accept.c
  27. +2 −2 test/test-embed.c
  28. +9 −9 test/test-fs-event.c
  29. +1 −1 test/test-fs-poll.c
  30. +38 −38 test/test-fs.c
  31. +2 −2 test/test-getaddrinfo.c
  32. +2 −2 test/test-getsockname.c
  33. +1 −1 test/test-idle.c
  34. +2 −2 test/test-ipc-send-recv.c
  35. +3 −3 test/test-ipc.c
  36. +1 −1 test/test-loop-handles.c
  37. +1 −1 test/test-multiple-listen.c
  38. +3 −3 test/test-ping-pong.c
  39. +4 −4 test/test-pipe-bind-error.c
  40. +2 −2 test/test-pipe-connect-error.c
  41. +1 −1 test/test-poll-close.c
  42. +1 −1 test/test-poll.c
  43. +24 −24 test/test-ref.c
  44. +1 −1 test/test-run-nowait.c
  45. +1 −1 test/test-run-once.c
  46. +2 −2 test/test-shutdown-close.c
  47. +1 −1 test/test-shutdown-eof.c
  48. +4 −4 test/test-signal-multiple-loops.c
  49. +4 −4 test/test-signal.c
  50. +19 −19 test/test-spawn.c
  51. +3 −3 test/test-stdio-over-pipes.c
  52. +5 −5 test/test-tcp-bind-error.c
  53. +4 −4 test/test-tcp-bind6-error.c
  54. +1 −1 test/test-tcp-close-while-connecting.c
  55. +1 −1 test/test-tcp-close.c
  56. +1 −1 test/test-tcp-connect-error-after-write.c
  57. +1 −1 test/test-tcp-connect-error.c
  58. +1 −1 test/test-tcp-connect-timeout.c
  59. +1 −1 test/test-tcp-connect6-error.c
  60. +1 −1 test/test-tcp-flags.c
  61. +1 −1 test/test-tcp-open.c
  62. +1 −1 test/test-tcp-read-stop.c
  63. +1 −1 test/test-tcp-shutdown-after-write.c
  64. +1 −1 test/test-tcp-unexpected-read.c
  65. +1 −1 test/test-tcp-write-to-half-open-connection.c
  66. +1 −1 test/test-tcp-writealot.c
  67. +1 −1 test/test-thread.c
  68. +5 −5 test/test-threadpool-cancel.c
  69. +2 −2 test/test-threadpool.c
  70. +1 −1 test/test-timer-again.c
  71. +2 −2 test/test-timer.c
  72. +1 −1 test/test-tty.c
  73. +1 −1 test/test-udp-dgram-too-big.c
  74. +1 −1 test/test-udp-ipv6.c
  75. +1 −1 test/test-udp-multicast-join.c
  76. +1 −1 test/test-udp-multicast-ttl.c
  77. +1 −1 test/test-udp-open.c
  78. +1 −1 test/test-udp-options.c
  79. +1 −1 test/test-udp-send-and-recv.c
  80. +1 −1 test/test-walk-handles.c
View
@@ -245,12 +245,6 @@ UV_EXTERN void uv_loop_delete(uv_loop_t*);
UV_EXTERN uv_loop_t* uv_default_loop(void);
/*
- * This function starts the event loop. It blocks until the reference count
- * of the loop drops to zero. Always returns zero.
- */
-UV_EXTERN int uv_run(uv_loop_t*);
-
-/*
* This function runs the event loop. It will act differently depending on the
* specified mode:
* - UV_RUN_DEFAULT: Runs the event loop until the reference count drops to
@@ -262,7 +256,7 @@ UV_EXTERN int uv_run(uv_loop_t*);
* - UV_RUN_NOWAIT: Poll for new events once but don't block if there are no
* pending events.
*/
-UV_EXTERN int uv_run2(uv_loop_t*, uv_run_mode mode);
+UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode);
/*
* Manually modify the event loop's reference count. Useful if the user wants
View
@@ -279,7 +279,7 @@ static int uv__loop_alive(uv_loop_t* loop) {
}
-int uv_run2(uv_loop_t* loop, uv_run_mode mode) {
+int uv_run(uv_loop_t* loop, uv_run_mode mode) {
int r;
if (!uv__loop_alive(loop))
@@ -301,11 +301,6 @@ int uv_run2(uv_loop_t* loop, uv_run_mode mode) {
}
-int uv_run(uv_loop_t* loop) {
- return uv_run2(loop, UV_RUN_DEFAULT);
-}
-
-
void uv_update_time(uv_loop_t* loop) {
uv__update_time(loop);
}
View
@@ -252,7 +252,7 @@ static void uv_poll_ex(uv_loop_t* loop, int block) {
!ngx_queue_empty(&(loop)->active_reqs) || \
(loop)->endgame_handles != NULL)
-int uv_run2(uv_loop_t *loop, uv_run_mode mode) {
+int uv_run(uv_loop_t *loop, uv_run_mode mode) {
int r;
void (*poll)(uv_loop_t* loop, int block);
@@ -291,8 +291,3 @@ int uv_run2(uv_loop_t *loop, uv_run_mode mode) {
}
return r;
}
-
-
-int uv_run(uv_loop_t* loop) {
- return uv_run2(loop, UV_RUN_DEFAULT);
-}
@@ -78,7 +78,7 @@ static int test_async_pummel(int nthreads) {
time = uv_hrtime();
- ASSERT(0 == uv_run(uv_default_loop()));
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
time = uv_hrtime() - time;
done = 1;
@@ -67,7 +67,7 @@ static void main_async_cb(uv_async_t* handle, int status) {
static void worker(void* arg) {
struct ctx* ctx = arg;
ASSERT(0 == uv_async_send(&ctx->main_async));
- ASSERT(0 == uv_run(ctx->loop));
+ ASSERT(0 == uv_run(ctx->loop, UV_RUN_DEFAULT));
}
@@ -92,7 +92,7 @@ static int test_async(int nthreads) {
time = uv_hrtime();
- ASSERT(0 == uv_run(uv_default_loop()));
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
for (i = 0; i < nthreads; i++)
ASSERT(0 == uv_thread_join(&threads[i].thread));
@@ -51,7 +51,7 @@ static void warmup(const char* path) {
for (i = 0; i < ARRAY_SIZE(reqs); i++)
uv_fs_stat(uv_default_loop(), reqs + i, path, uv_fs_req_cleanup);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
/* warm up the OS dirent cache */
for (i = 0; i < 16; i++)
@@ -108,7 +108,7 @@ static void async_bench(const char* path) {
}
before = uv_hrtime();
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
after = uv_hrtime();
printf("%s stats (%d concurrent): %.2fs (%s/s)\n",
@@ -75,7 +75,7 @@ BENCHMARK_IMPL(getaddrinfo) {
getaddrinfo_initiate(&handles[i]);
}
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
uv_update_time(loop);
end_time = uv_now(loop);
@@ -57,7 +57,7 @@ BENCHMARK_IMPL(loop_count) {
uv_idle_start(&idle_handle, idle_cb);
ns = uv_hrtime();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ns = uv_hrtime() - ns;
ASSERT(ticks == NUM_TICKS);
@@ -81,7 +81,7 @@ BENCHMARK_IMPL(loop_count_timed) {
uv_timer_init(loop, &timer_handle);
uv_timer_start(&timer_handle, timer_cb, 5000, 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
LOGF("loop_count: %lu ticks (%.0f ticks/s)\n", ticks, ticks / 5.0);
@@ -99,7 +99,7 @@ BENCHMARK_IMPL(million_async) {
ASSERT(0 == uv_timer_init(loop, &timer_handle));
ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, timeout, 0));
ASSERT(0 == uv_thread_create(&thread_id, thread_cb, NULL));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
printf("%s async events in %.1f seconds (%s/s, %s unique handles seen)\n",
fmt(container->async_events),
timeout / 1000.,
@@ -59,13 +59,13 @@ BENCHMARK_IMPL(million_timers) {
}
before = uv_hrtime();
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
after = uv_hrtime();
for (i = 0; i < NUM_TIMERS; i++)
uv_close((uv_handle_t*) (timers + i), close_cb);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(timer_cb_called == NUM_TIMERS);
ASSERT(close_cb_called == NUM_TIMERS);
free(timers);
@@ -214,9 +214,9 @@ static void send_listen_handles(uv_handle_type type,
for (i = 0; i < num_servers; i++)
uv_sem_post(&servers[i].semaphore);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
uv_close((uv_handle_t*) &ctx.server_handle, NULL);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
for (i = 0; i < num_servers; i++)
uv_sem_wait(&servers[i].semaphore);
@@ -234,7 +234,7 @@ static void get_listen_handle(uv_loop_t* loop, uv_stream_t* server_handle) {
&ctx.ipc_pipe,
IPC_PIPE_NAME,
ipc_connect_cb);
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
}
@@ -258,7 +258,7 @@ static void server_cb(void *arg) {
ASSERT(0 == uv_listen((uv_stream_t*) &ctx->server_handle,
128,
sv_connection_cb));
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
uv_loop_delete(loop);
}
@@ -383,7 +383,7 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) {
{
uint64_t t = uv_hrtime();
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
t = uv_hrtime() - t;
time = t / 1e9;
}
@@ -203,7 +203,7 @@ BENCHMARK_IMPL(ping_pongs) {
start_time = uv_now(loop);
pinger_new();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(completed_pingers == 1);
@@ -287,7 +287,7 @@ static int pound_it(int concurrency,
r = do_connect(concurrency, make_connect, arg);
ASSERT(!r);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
end_time = uv_hrtime();
@@ -373,7 +373,7 @@ HELPER_IMPL(tcp_pump_server) {
r = uv_listen((uv_stream_t*)&tcpServer, MAX_WRITE_HANDLES, connection_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
@@ -394,7 +394,7 @@ HELPER_IMPL(pipe_pump_server) {
r = uv_listen((uv_stream_t*)&pipeServer, MAX_WRITE_HANDLES, connection_cb);
ASSERT(r == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
MAKE_VALGRIND_HAPPY();
return 0;
@@ -413,7 +413,7 @@ static void tcp_pump(int n) {
/* Start making connections */
maybe_connect_some();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
MAKE_VALGRIND_HAPPY();
}
@@ -429,7 +429,7 @@ static void pipe_pump(int n) {
/* Start making connections */
maybe_connect_some();
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
MAKE_VALGRIND_HAPPY();
}
@@ -149,7 +149,7 @@ BENCHMARK_IMPL(spawn) {
spawn();
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
uv_update_time(loop);
@@ -122,7 +122,7 @@ BENCHMARK_IMPL(tcp_write_batch) {
start = uv_hrtime();
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);
stop = uv_hrtime();
@@ -195,7 +195,7 @@ static int pummel(unsigned int n_senders,
}
duration = uv_hrtime();
- ASSERT(0 == uv_run(loop));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
duration = uv_hrtime() - duration;
/* convert from nanoseconds to milliseconds */
duration = duration / (uint64_t) 1e6;
@@ -111,7 +111,7 @@ HELPER_IMPL(tcp4_blackhole_server) {
r = uv_listen((uv_stream_t*)&tcp_server, 128, connection_cb);
ASSERT(r == 0);
- r = uv_run(loop);
+ r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(0 && "Blackhole server dropped out of event loop.");
return 0;
View
@@ -324,6 +324,6 @@ HELPER_IMPL(dns_server) {
if (dns_start(TEST_PORT_2))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
View
@@ -346,7 +346,7 @@ HELPER_IMPL(tcp4_echo_server) {
if (tcp4_echo_start(TEST_PORT))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
@@ -357,7 +357,7 @@ HELPER_IMPL(tcp6_echo_server) {
if (tcp6_echo_start(TEST_PORT))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
@@ -368,7 +368,7 @@ HELPER_IMPL(pipe_echo_server) {
if (pipe_echo_start(TEST_PIPENAME))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
@@ -379,6 +379,6 @@ HELPER_IMPL(udp4_echo_server) {
if (udp4_echo_start(TEST_PORT))
return 1;
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
View
@@ -73,7 +73,7 @@ TEST_IMPL(active) {
ASSERT(!uv_is_active((uv_handle_t*) &timer));
ASSERT(uv_is_closing((uv_handle_t*) &timer));
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(close_cb_called == 1);
View
@@ -122,7 +122,7 @@ TEST_IMPL(async) {
r = uv_async_init(uv_default_loop(), &async, async_cb);
ASSERT(r == 0);
- r = uv_run(uv_default_loop());
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
ASSERT(prepare_cb_called > 0);
@@ -67,7 +67,7 @@ TEST_IMPL(callback_order) {
ASSERT(idle_cb_called == 0);
ASSERT(timer_cb_called == 0);
- uv_run(loop);
+ uv_run(loop, UV_RUN_DEFAULT);
ASSERT(idle_cb_called == 1);
ASSERT(timer_cb_called == 1);
@@ -189,7 +189,7 @@ TEST_IMPL(callback_stack) {
}
nested--;
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(nested == 0);
ASSERT(connect_cb_called == 1 && "connect_cb must be called exactly once");
@@ -107,7 +107,7 @@ static void connection_fail(uv_connect_cb connect_cb) {
r = uv_tcp_connect(&req, &tcp, server_addr, connect_cb);
ASSERT(!r);
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connect_cb_calls == 1);
ASSERT(close_cb_calls == 1);
@@ -177,7 +177,7 @@ TEST_IMPL(delayed_accept) {
client_connect();
client_connect();
- uv_run(uv_default_loop());
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(connection_cb_called == 2);
ASSERT(do_accept_called == 2);
Oops, something went wrong. Retry.

0 comments on commit 4ba03dd

Please sign in to comment.