Rework Timer and SafeTimer to be more efficient and to handle shutdown
correctly. Document the API, especially what locks need to held where.
The destructor for both Timer and SafeTimer now joins the timer thread
safely. The shutdown() function is available to callers who want to join
it before the Timer is destroyed.
To make things more efficient, don't create a new std::set every time we
insert a Context. Use multimap instead. Don't signal the condition
variable unless the event we have insert comes before all the other
events in the scheduled map. Don't allocate an extra Context in
SafeTimer.
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
A couple of preprocessor symbols for include guards tampered with the reserved namespace.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Sage Weil <sage@newdream.net>