Fix error checking and assertions.
Don't depend on <unistd.h> being included previously for _POSIX_TIMERS.
Merge synchronization fixes for TimeoutQueues.
Release the interest queue mutex when draining.
Make CallbackQueue more resilient against races.