summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/PeriodicTimer.h
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-01-27 22:20:51 +0000
committerAlan Conway <aconway@apache.org>2010-01-27 22:20:51 +0000
commit1297c818282f26838776df418d846e07457a7f7f (patch)
treed69c3b15f76b9d83a62462df3ca5211a45be7a4b /cpp/src/qpid/sys/PeriodicTimer.h
parentd0df2e739d5fba4bfb9f549720518e55d6fa9c9c (diff)
downloadqpid-python-1297c818282f26838776df418d846e07457a7f7f.tar.gz
Added PeriodicTimer interface for periodic tasks that need cluster synchronization.
The ManagementAgent's periodic prociessing uses PeriodicTimer. PeriodicTimerImpl is the default implementation for stand-alone brokers, simple wrapper for sys::Timer. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@903866 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/PeriodicTimer.h')
-rw-r--r--cpp/src/qpid/sys/PeriodicTimer.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/cpp/src/qpid/sys/PeriodicTimer.h b/cpp/src/qpid/sys/PeriodicTimer.h
new file mode 100644
index 0000000000..290ffb6218
--- /dev/null
+++ b/cpp/src/qpid/sys/PeriodicTimer.h
@@ -0,0 +1,56 @@
+#ifndef QPID_SYS_PERIODICTIMER_H
+#define QPID_SYS_PERIODICTIMER_H
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "Timer.h"
+#include <boost/function.hpp>
+
+namespace qpid {
+namespace sys {
+
+/**
+ * Interface of a timer for periodic tasks that should be synchronized
+ * across all brokers in a periodic. The standalone broker
+ * implementation simply wraps qpid::sys::Timer. The clustered broker
+ * implementation synchronizes execution of periodic tasks on all
+ * periodic members.
+ */
+class PeriodicTimer
+{
+ public:
+ typedef boost::function<void()> Task;
+
+ QPID_COMMON_EXTERN virtual ~PeriodicTimer() {}
+
+ /**
+ * Add a named task to be executed at the given period.
+ *
+ * The task registered under the same name will be executed on
+ * all brokers at the given period.
+ */
+ virtual void add(const Task& task, Duration period, const std::string& taskName) = 0;
+
+};
+}} // namespace qpid::sys
+
+#endif /*!QPID_SYS_PERIODICTIMER_H*/