Implement edge-triggered event waiting

Mostly just minor changes in the object type wait callbacks. Also
changed the semantics of the timer object event. Previously the fired
state would be cleared when the event is received by a wait call. Now
the behaviour depends on the timer mode: for one shot mode, the fired
state remains set until the timer is restarted or stopped, so a level-
triggered wait after the event has fired will always be signalled
immediately. For periodic mode, it is cleared after each period, so
it always has edge-triggered behaviour.