Alien-uv
view release on metacpan or search on metacpan
libuv/test/test-loop-handles.c view on Meta::CPAN
/*
* Purpose of this test is to check semantics of starting and stopping
* prepare, check and idle watchers.
*
* - A watcher must be able to safely stop or close itself;
* - Once a watcher is stopped or closed its callback should never be called.
* - If a watcher is closed, it is implicitly stopped and its close_cb should
* be called exactly once.
* - A watcher can safely start and stop other watchers of the same type.
* - Prepare and check watchers are called once per event loop iterations.
* - All active idle watchers are queued when the event loop has no more work
* to do. This is done repeatedly until all idle watchers are inactive.
* - If a watcher starts another watcher of the same type its callback is not
* immediately queued. For check and prepare watchers, that means that if
* a watcher makes another of the same type active, it'll not be called until
* the next event loop iteration. For idle. watchers this means that the
* newly activated idle watcher might not be queued immediately.
* - Prepare, check, idle watchers keep the event loop alive even when they're
* not active.
*
* This is what the test globally does:
*
* - prepare_1 is always active and counts event loop iterations. It also
* creates and starts prepare_2 every other iteration. Finally it verifies
* that no idle watchers are active before polling.
* - prepare_2 is started by prepare_1 every other iteration. It immediately
* stops itself. It verifies that a watcher is not queued immediately
* if created by another watcher of the same type.
* - There's a check watcher that stops the event loop after a certain number
* of iterations. It starts a varying number of idle_1 watchers.
* - Idle_1 watchers stop themselves after being called a few times. All idle_1
* watchers try to start the idle_2 watcher if it is not already started or
* awaiting its close callback.
* - The idle_2 watcher always exists but immediately closes itself after
* being started by a check_1 watcher. It verifies that a watcher is
* implicitly stopped when closed, and that a watcher can close itself
* safely.
* - There is a repeating timer. It does not keep the event loop alive
* (ev_unref) but makes sure that the loop keeps polling the system for
* events.
( run in 1.798 second using v1.01-cache-2.11-cpan-96521ef73a4 )