looks reasonable. ack
On Sun, Jun 19, 2011 at 12:25 AM, Russell Bryant
<russell(a)russellbryant.net> wrote:
This patch makes heartbeat_timer() a static member function of
HostAgent. It also makes it so heartbeat() can be private. Also add
some documentation for these functions.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
src/host/host-qmf.cpp | 43 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/src/host/host-qmf.cpp b/src/host/host-qmf.cpp
index 7547daf..2397492 100644
--- a/src/host/host-qmf.cpp
+++ b/src/host/host-qmf.cpp
@@ -17,6 +17,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/**
+ * \file
+ * \brief Host QMF Agent
+ */
+
#ifndef WIN32
#include "config.h"
#endif
@@ -35,19 +40,43 @@ extern "C" {
class HostAgent : public MatahariAgent
{
-private:
- qmf::org::matahariproject::PackageDefinition _package;
public:
- int heartbeat();
virtual int setup(qmf::AgentSession session);
virtual gboolean invoke(qmf::AgentSession session, qmf::AgentEvent event,
gpointer user_data);
+
+ /**
+ * Send a heartbeat and reset the timer.
+ *
+ * This function should be called a single time after the HostAgent
+ * is created. From then on it will automatically reschedule itself
+ * to be called.
+ *
+ * \param[in] data a pointer to the HostAgent
+ *
+ * \retval FALSE always
+ */
+ static gboolean heartbeat_timer(gpointer data);
+
+private:
+ /**
+ * Send HostAgent heartbeat.
+ *
+ * This function gets scheduled to be called periodically in
+ * heartbeat_timer().
+ *
+ * \return the number of milliseconds until the next time heartbeat()
+ * should be called.
+ */
+ int heartbeat();
+
+ qmf::org::matahariproject::PackageDefinition _package;
};
-static gboolean
-heartbeat_timer(gpointer data)
+gboolean
+HostAgent::heartbeat_timer(gpointer data)
{
- HostAgent *agent = (HostAgent *)data;
+ HostAgent *agent = (HostAgent *) data;
g_timeout_add(agent->heartbeat(), heartbeat_timer, data);
return FALSE;
}
@@ -58,7 +87,7 @@ main(int argc, char **argv)
HostAgent *agent = new HostAgent();
int rc = agent->init(argc, argv, "host");
if (rc == 0) {
- heartbeat_timer(agent);
+ HostAgent::heartbeat_timer(agent);
agent->run();
}
--
1.7.5.4
_______________________________________________
Matahari mailing list
Matahari(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/matahari