1
0
mirror of https://github.com/libuv/libuv synced 2025-03-28 21:13:16 +00:00

unix: make uv_timer_init() initialize repeat

uv_timer_get_repeat() should return 0 for timers that haven't been
started.
This commit is contained in:
Brian Mazza 2013-03-04 22:17:50 -06:00 committed by Ben Noordhuis
parent a9740c9bc4
commit 77cb29a723
3 changed files with 15 additions and 0 deletions

View File

@ -45,6 +45,7 @@ RB_GENERATE_STATIC(uv__timers, uv_timer_s, tree_entry, uv__timer_cmp)
int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) {
uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER);
handle->timer_cb = NULL;
handle->repeat = 0;
return 0;
}

View File

@ -95,6 +95,7 @@ TEST_DECLARE (shutdown_eof)
TEST_DECLARE (callback_stack)
TEST_DECLARE (error_message)
TEST_DECLARE (timer)
TEST_DECLARE (timer_init)
TEST_DECLARE (timer_again)
TEST_DECLARE (timer_start_twice)
TEST_DECLARE (timer_order)
@ -336,6 +337,7 @@ TASK_LIST_START
TEST_ENTRY (error_message)
TEST_ENTRY (timer)
TEST_ENTRY (timer_init)
TEST_ENTRY (timer_again)
TEST_ENTRY (timer_start_twice)
TEST_ENTRY (timer_order)

View File

@ -156,6 +156,18 @@ TEST_IMPL(timer_start_twice) {
}
TEST_IMPL(timer_init) {
uv_timer_t handle;
ASSERT(0 == uv_timer_init(uv_default_loop(), &handle));
ASSERT(0 == uv_timer_get_repeat(&handle));
ASSERT(!uv_is_active((uv_handle_t*)&handle));
MAKE_VALGRIND_HAPPY();
return 0;
}
static void order_cb_a(uv_timer_t *handle, int status) {
ASSERT(order_cb_called++ == *(int*)handle->data);
}