
Module: ppl/ppl Branch: master Commit: 9bdd6617be52573d3252687844d32001e671a126 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=9bdd6617be525...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Wed Feb 17 11:56:08 2010 +0100
Cater for systems where setitimer() is not provided (part 1).
---
Watchdog/src/Watchdog.defs.hh | 4 ++++ Watchdog/src/Watchdog.inlines.hh | 32 ++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/Watchdog/src/Watchdog.defs.hh b/Watchdog/src/Watchdog.defs.hh index eace4b3..3b1b3ba 100644 --- a/Watchdog/src/Watchdog.defs.hh +++ b/Watchdog/src/Watchdog.defs.hh @@ -61,6 +61,8 @@ public: //! Destructor. ~Watchdog();
+#if HAVE_DECL_SETITIMER + private: typedef Pending_List<Watchdog_Traits> WD_Pending_List; friend class Init; @@ -130,6 +132,8 @@ private: static volatile bool in_critical_section;
friend void PWL_handle_timeout(int signum); + +#endif // HAVE_DECL_SETITIMER };
class Init { diff --git a/Watchdog/src/Watchdog.inlines.hh b/Watchdog/src/Watchdog.inlines.hh index 47340fc..a24dd35 100644 --- a/Watchdog/src/Watchdog.inlines.hh +++ b/Watchdog/src/Watchdog.inlines.hh @@ -29,10 +29,7 @@ site: http://www.cs.unipr.it/ppl/ . */
namespace Parma_Watchdog_Library {
-inline void -Watchdog::reschedule() { - set_timer(reschedule_time); -} +#if HAVE_DECL_SETITIMER
template <typename Flag_Base, typename Flag> Watchdog::Watchdog(unsigned int units, @@ -58,6 +55,33 @@ Watchdog::Watchdog(unsigned int units, void (*function)()) in_critical_section = false; }
+inline void +Watchdog::reschedule() { + set_timer(reschedule_time); +} + +#else // !HAVE_DECL_SETITIMER + +template <typename Flag_Base, typename Flag> +Watchdog::Watchdog(unsigned int units, + const Flag_Base* volatile& holder, Flag& flag) { + used(units); + used(holder); + used(flag); + throw std::runtime_error("PWL::Watchdog objects not supported:" + " system does not provide setitimer()"); +} + +inline +Watchdog::Watchdog(unsigned int units, void (*function)()) { + used(units); + used(function); + throw std::runtime_error("PWL::Watchdog objects not supported:" + " system does not provide setitimer()"); +} + +#endif // HAVE_DECL_SETITIMER + inline Init::Init() { // Only when the first Init object is constructed...