async-interop / event-loop

An event loop interface for interoperability in PHP.
MIT License
170 stars 9 forks source link

Throw on invalid watcher identifier #63

Closed trowski closed 8 years ago

trowski commented 8 years ago

Addresses #58. Adds InvalidWatcherExeption that should be thrown if enable, disable, cancel, reference, or unreference is attempted with an invalid watcher identifier.

bwoebi commented 8 years ago

I'd explicitly specify invalid or cancelled. This eliminates every ambiguity. Cancelling may or may not invalidate the watcher internally immediately. The guarantee is that it will be invalidated after the next tick and will not be called after cancellation anymore.

bwoebi commented 8 years ago

Do we maybe want to explicitly add (on Driver interface) that disable() never invalidates a watcher?

trowski commented 8 years ago

I agree, I'll add that as well.

kelunik commented 8 years ago

Cancelling may or may not invalidate the watcher internally immediately.

I'd say it should do that immediately.

bwoebi commented 8 years ago

@kelunik yes, should. But that's an implementation detail we have no control of.

kelunik commented 8 years ago

It's something we can define. Then we have the control.

bwoebi commented 8 years ago

It may eventually depend on the loop implementation. I.e. uv internally only releases it on the next tick. (to avoid freed memory access; see also uv_close() on libuv docs)