Heartbeat updates

The last parameter to stasher::heartbeat's constructor is a functor that takes a stasher::heartbeat<application_id,application_status>::base::update_type_t parameter. stasher::heartbeat uses a timer thread to invoke this functor periodically, according to the refresh interval. The functor can also get invoked for other reasons.

The update_type_t parameter is an opaque value. The expected result from invoking the functor is that the heartbeat object's update() gets invoked. update() takes two parameters, the original update_type_t value that the functor received, and an application_status representing the application instance's current status, which gets posted as the instance's current heartbeat.

The update functor does not typically invoke the heartbeat object's update(). The functor gets passed to stasher::heartbeat's constructor, so the functor gets created before the heartbeat object. The example in the next section shows the recommended implementation of the update functor: the only thing it does is send a message to a thread that takes the constructed hearbeat object as a parameter to its run(), and the thread invokes update() when it gets the update message. The functor gets typically invoked from the client connection thread, and it can't afford to engage in lengthy, time consuming duties. Having the update functor only send a message to a thread is the recommended approach.