Commit Graph

17 Commits

Author SHA1 Message Date
Ben Noordhuis
028fef84b8 unix: update timer if already active
uv_timer_start() no longer returns an error when the timer is already active,
now it just updates the timer. Consistent with the uv-win implementation.

Fixes #425.
2012-05-26 02:09:59 +02:00
Ben Noordhuis
ae9d4c2aab test: add 'is active?' checks to test-timer.c 2012-05-26 01:57:49 +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
dd7e6f0163 test: don't use malloc/free in test-timer 2012-01-18 19:00:55 +01:00
Ben Noordhuis
ac218a7ed5 test: add lots of refcount tests 2012-01-14 00:22:20 +01:00
Ryan Dahl
3e5aa06c49 Add two timer ref count tests 2011-09-26 22:01:21 -07: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
Ryan Dahl
ce8ff3031c src/ and include/ directories
Helps #71 but does not update the MSVC files.
2011-07-07 07:52:57 -07:00
Bert Belder
4eb06151bd Split up uv_loop type 2011-06-17 23:00:39 +02:00
Ryan Dahl
04b6aaeb44 API Change: Move close_cb to uv_close from init functions 2011-06-08 05:44:22 -07:00
Ryan Dahl
7db9629f87 API Change: Remove data parameters from init functions 2011-06-08 05:43:02 -07:00
Ryan Dahl
7770b1a1f6 API change: alloc_cb moved to uv_read_start()
Fixes #47.
2011-06-03 02:30:00 -07:00
Ryan Dahl
11a4ad50c8 Separate out uv_handle_t into different types
Fixes #4
2011-06-03 11:03:52 +02:00
Ryan Dahl
816289ae8f unix: implement timers
currently loop_handles is broken.
2011-05-16 17:08:43 -07:00
Bert Belder
810651e04c Update tests & benchmarks to use the new timer api 2011-05-17 01:17:48 +02:00