root/trunk/libffado/src/libutil/Watchdog.h

Revision 2803, 3.2 kB (checked in by jwoithe, 3 years ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free FireWire (pro-)audio drivers for Linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #ifndef __FFADO_WATCHDOG__
25 #define __FFADO_WATCHDOG__
26
27 #include "debugmodule/debugmodule.h"
28 #include "libutil/Thread.h"
29
30 namespace Util {
31
32 typedef std::vector<Thread *> ThreadVector;
33 typedef std::vector<Thread *>::iterator ThreadVectorIterator;
34
35 class IsoHandlerManager;
36
37 class Watchdog
38 {
39 private:
40     class WatchdogTask : public Util::RunnableInterface
41     {
42     public:
43         WatchdogTask(Watchdog& parent, unsigned int interval_usecs);
44         virtual ~WatchdogTask();
45
46         bool Init();
47         bool Execute();
48         void ReqStop();
49         Watchdog& m_parent;
50     private:
51         unsigned int m_interval;
52         int stop_msg_pipe[2];
53         DECLARE_DEBUG_MODULE_REFERENCE;
54     };
55
56     class WatchdogCheckTask : public WatchdogTask
57     {
58     public:
59         WatchdogCheckTask(Watchdog& parent, unsigned int interval_usecs);
60         virtual ~WatchdogCheckTask() {};
61
62         bool Init();
63         bool Execute();
64     private:
65         // debug stuff
66         #ifdef DEBUG
67             uint64_t m_last_loop_entry;
68             int m_successive_short_loops;
69         #endif
70         DECLARE_DEBUG_MODULE_REFERENCE;
71     };
72
73     class WatchdogHartbeatTask : public WatchdogTask
74     {
75     public:
76         WatchdogHartbeatTask(Watchdog& parent, unsigned int interval_usecs);
77         virtual ~WatchdogHartbeatTask() {};
78
79         bool Init();
80         bool Execute();
81     private:
82         // debug stuff
83         #ifdef DEBUG
84             uint64_t m_last_loop_entry;
85             int m_successive_short_loops;
86         #endif
87         DECLARE_DEBUG_MODULE_REFERENCE;
88     };
89
90 public:
91     Watchdog();
92     Watchdog(unsigned int interval_usec, bool realtime, unsigned int priority);
93     virtual ~Watchdog();
94
95     bool registerThread(Thread *thread);
96     bool unregisterThread(Thread *thread);
97
98     bool start();
99
100     bool setThreadParameters(bool rt, int priority);
101
102     void setVerboseLevel(int i);
103
104 protected:
105     bool getHartbeat() {return m_hartbeat;};
106     void clearHartbeat() {m_hartbeat=false;};
107     void setHartbeat() {m_hartbeat=true;};
108
109     void rescheduleThreads();
110
111 private:
112     ThreadVector    m_Threads;
113     bool            m_hartbeat;
114
115     unsigned int    m_check_interval;
116     bool            m_realtime;
117     int             m_priority;
118     Util::Thread *  m_CheckThread;
119     Util::Thread *  m_HartbeatThread;
120     WatchdogCheckTask *     m_CheckTask;
121     WatchdogHartbeatTask *  m_HartbeatTask;
122
123     DECLARE_DEBUG_MODULE;
124 };
125
126 } // end of namespace Util
127
128 #endif /* __FFADO_WATCHDOG__ */
129
130
Note: See TracBrowser for help on using the browser.