Commit Graph

17 Commits

Author SHA1 Message Date
Ben Noordhuis
4ba03ddd56 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.
2013-01-16 23:35:29 +01:00
Ben Noordhuis
fb725c0893 test: simplify tcp_ref2b
Said test doesn't need its own close callback, it can piggyback on the
common close callback.
2013-01-06 22:31:48 +01:00
Ben Noordhuis
7ff6f29b85 test, bench: ANSI-fy function prototypes
Replace `void f()` with `void f(void)`; the former means "a function
that takes any number of arguments, including none" while the latter
is what is actually intended: a function taking no arguments.

The first form also isn't strictly conforming ANSI/ISO C.
2013-01-06 22:31:48 +01:00
Saúl Ibarra Corretgé
33d5c497a6 prepare/idle/check: don't allow NULL callback 2012-12-24 17:05:01 +01:00
Bert Belder
149b16f123 windows: closing handles should always keep the loop alive
This makes the tcp-ref2 and udp-ref2 tests pass again.
Also adds another reference count test.
2012-10-25 15:10:29 +02:00
Bert Belder
47eb03490a test: move loop cleanup code to the individual tests 2012-10-17 01:24:49 +02:00
Ben Noordhuis
678e95a443 test: close handle in ref tests
Everything that gets reported by valgrind now is an actual memory leak.
2012-10-01 22:53:59 +02:00
Ben Noordhuis
cc7c8542a5 unix, windows: add stat() based file watcher
Monitors a file path for changes. Supersedes ev_stat.
2012-05-31 20:32:24 +02:00
Ben Noordhuis
9efa8b3571 unix, windows: rework reference counting scheme
This commit changes how the event loop determines if it needs to stay alive.

Previously, an internal counter was increased whenever a handle got created
and decreased again when the handle was closed.

While conceptually simple, it turned out hard to work with: you often want
to keep the event loop alive only if the handle is actually doing something.
Stopped or inactive handles were a frequent source of hanging event loops.

That's why this commit changes the reference counting scheme to a model where
a handle only references the event loop when it's active. 'Active' means
different things for different handle types, e.g.:

 * timers: ticking
 * sockets: reading, writing or listening
 * processes: always active (for now, subject to change)
 * idle, check, prepare: only active when started

This commit also changes how the uv_ref() and uv_unref() functions work: they
now operate on the level of individual handles, not the whole event loop.

The Windows implementation was done by Bert Belder.
2012-05-17 07:07:53 +02:00
Ben Noordhuis
8c78cb40ff unix: replace C99/C++ comments, fix build 2012-03-09 09:15:43 -08:00
Bert Belder
fb65d74c84 Tests: verify that uv_write and uv_shutdown ref the event loop 2012-03-09 05:00:11 +01:00
Ben Noordhuis
ac218a7ed5 test: add lots of refcount tests 2012-01-14 00:22:20 +01:00
Bert Belder
0dc564a2aa Remove uv_init calls from tests and benchmarks 2011-09-12 11:32:41 -07:00
Bert Belder
3aec77f9d4 bring back uv_init 2011-08-31 04:19:07 +02:00
Ryan Dahl
56dcaf9b06 unix: multiplicity 2011-08-31 04:18:55 +02:00
Bert Belder
1ab28df433 Test that loop refs going down to zero in a prepare callback does not hang the event loop 2011-07-21 14:53:40 +02:00
Bert Belder
9d8c9cce7c Move loop reference tests to their own file 2011-07-21 14:51:56 +02:00