PPL  1.2
Threshold_Watcher_defs.hh
Go to the documentation of this file.
1 /* Threshold_Watcher and associated classes' declaration and inline functions.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Threshold_Watcher_defs_hh
25 #define PPL_Threshold_Watcher_defs_hh 1
26 
28 #include "Handler_types.hh"
29 #include "Pending_List_defs.hh"
30 #include <cassert>
31 
39 template <typename Traits>
41 public:
42  template <typename Flag_Base, typename Flag>
43  Threshold_Watcher(const typename Traits::Delta& delta,
44  const Flag_Base* volatile& holder,
45  Flag& flag);
46 
47  Threshold_Watcher(const typename Traits::Delta& delta,
48  void (*function)());
49 
51 
52 private:
55 
56  bool expired;
57  const TW_Handler& handler;
59 
60  // Just to prevent their use.
63 
64  struct Initialize {
66  TW_Pending_List pending;
67  };
68  static Initialize init;
69 
70  // Handle the addition of a new threshold.
71  static typename TW_Pending_List::iterator
72  add_threshold(typename Traits::Threshold threshold,
73  const TW_Handler& handler,
74  bool& expired_flag);
75 
76  // Handle the removal of a threshold.
77  static typename TW_Pending_List::iterator
79 
81  static void check();
82 
83 }; // class Parma_Polyhedra_Library::Threshold_Watcher
84 
85 
86 // Templatic initialization of static data member.
87 template <typename Traits>
88 typename
91 
94 
95 #endif // !defined(PPL_Threshold_Watcher_defs_hh)
96 
Abstract base class for handlers of the watchdog events.
Definition: Handler_defs.hh:30
static TW_Pending_List::iterator add_threshold(typename Traits::Threshold threshold, const TW_Handler &handler, bool &expired_flag)
An ordered list for recording pending watchdog events.
A class of watchdogs controlling the exceeding of a threshold.
Implementation::Watchdog::Pending_List< Traits > TW_Pending_List
static void check()
Check threshold reaching.
A class providing iterators for embedded lists.
Threshold_Watcher & operator=(const Threshold_Watcher &)
TW_Pending_List pending
The ordered queue of pending thresholds.
Threshold_Watcher(const typename Traits::Delta &delta, const Flag_Base *volatile &holder, Flag &flag)
static TW_Pending_List::iterator remove_threshold(typename TW_Pending_List::iterator position)
Implementation::Watchdog::Handler TW_Handler