[PPL-devel] [GIT] ppl/ppl(master): Cater for systems where setitimer() is not provided (part 3).
Roberto Bagnara
bagnara at cs.unipr.it
Wed Feb 17 12:22:26 CET 2010
Module: ppl/ppl
Branch: master
Commit: eab6ab2fd4e44c8e7348c26112e4c9e4190e88ee
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=eab6ab2fd4e44c8e7348c26112e4c9e4190e88ee
Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date: Wed Feb 17 12:22:12 2010 +0100
Cater for systems where setitimer() is not provided (part 3).
---
Watchdog/src/Watchdog.cc | 10 ++++------
Watchdog/src/Watchdog.inlines.hh | 24 ++++++++++++++++++++----
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/Watchdog/src/Watchdog.cc b/Watchdog/src/Watchdog.cc
index 1b2fcb2..68ed01f 100644
--- a/Watchdog/src/Watchdog.cc
+++ b/Watchdog/src/Watchdog.cc
@@ -24,6 +24,8 @@ site: http://www.cs.unipr.it/ppl/ . */
#include "Watchdog.defs.hh"
+namespace PWL = Parma_Watchdog_Library;
+
#if PWL_HAVE_DECL_SETITIMER
#include <csignal>
@@ -54,8 +56,6 @@ site: http://www.cs.unipr.it/ppl/ . */
#define THE_SIGNAL SIGPROF
#endif
-namespace PWL = Parma_Watchdog_Library;
-
using std::cerr;
using std::endl;
@@ -222,11 +222,8 @@ PWL::Watchdog::remove_watchdog_event(WD_Pending_List::Iterator position) {
PWL::Time PWL::Watchdog::reschedule_time(1);
-#endif // PWL_HAVE_DECL_SETITIMER
-
void
PWL::Watchdog::initialize() {
-#if PWL_HAVE_DECL_SETITIMER
signal_once.it_interval.tv_sec = 0;
signal_once.it_interval.tv_usec = 0;
@@ -239,11 +236,12 @@ PWL::Watchdog::initialize() {
s.sa_flags = 0; // Was SA_ONESHOT: why?
my_sigaction(THE_SIGNAL, &s, 0);
-#endif // PWL_HAVE_DECL_SETITIMER
}
void
PWL::Watchdog::finalize() {
}
+#endif // PWL_HAVE_DECL_SETITIMER
+
unsigned int PWL::Init::count = 0;
diff --git a/Watchdog/src/Watchdog.inlines.hh b/Watchdog/src/Watchdog.inlines.hh
index 016926d..80258dd 100644
--- a/Watchdog/src/Watchdog.inlines.hh
+++ b/Watchdog/src/Watchdog.inlines.hh
@@ -71,6 +71,24 @@ Watchdog::reschedule() {
set_timer(reschedule_time);
}
+inline
+Init::Init() {
+ // Only when the first Init object is constructed...
+ if (count++ == 0) {
+ // ... the library is initialized.
+ Watchdog::initialize();
+ }
+}
+
+inline
+Init::~Init() {
+ // Only when the last Init object is destroyed...
+ if (--count == 0) {
+ // ... the library is finalized.
+ Watchdog::finalize();
+ }
+}
+
#else // !PWL_HAVE_DECL_SETITIMER
template <typename Flag_Base, typename Flag>
@@ -91,14 +109,11 @@ inline
Watchdog::~Watchdog() {
}
-#endif // !PWL_HAVE_DECL_SETITIMER
-
inline
Init::Init() {
// Only when the first Init object is constructed...
if (count++ == 0) {
// ... the library is initialized.
- Watchdog::initialize();
}
}
@@ -107,10 +122,11 @@ Init::~Init() {
// Only when the last Init object is destroyed...
if (--count == 0) {
// ... the library is finalized.
- Watchdog::finalize();
}
}
+#endif // !PWL_HAVE_DECL_SETITIMER
+
} // namespace Parma_Watchdog_Library
#endif // !defined(PWL_Watchdog_inlines_hh)
More information about the PPL-devel
mailing list