OpenCPN Partial API docs
Loading...
Searching...
No Matches
periodic_timer.h
Go to the documentation of this file.
1
/***************************************************************************
2
* Copyright (C) 2024 Alec Leamas *
3
* *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
8
* *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
13
* *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, see <https://www.gnu.org/licenses/>. *
16
**************************************************************************/
17
24
#ifndef _PERIODIC_TIMER_H
25
#define _PERIODIC_TIMER_H
26
27
#include <atomic>
28
#include <chrono>
29
#include <condition_variable>
30
#include <memory>
31
#include <mutex>
32
#include <string>
33
#include <thread>
34
44
class
PeriodicTimer
{
45
public
:
46
PeriodicTimer
(std::chrono::milliseconds interval);
47
48
virtual
~PeriodicTimer
();
49
50
void
Stop();
51
52
protected
:
53
virtual
void
Notify() = 0;
54
55
private
:
56
const
std::chrono::milliseconds m_interval;
57
std::mutex m_mutex;
58
std::condition_variable m_cond_var;
59
std::atomic<int> m_run_sts;
// 1 == running, 0 == request stop, -1 == stopped
60
std::thread m_thread;
61
62
void
Worker
();
63
};
64
65
#endif
// PERIODIC_TIMER_H
PeriodicTimer
Continuously run Notify with given interval.
Definition
periodic_timer.h:44
Worker
Manages reading the N2K data stream provided by some N2K gateways from the declared serial port.
Definition
comm_drv_n2k_socketcan.cpp:94
model
include
model
periodic_timer.h
Generated on Thu Oct 9 2025 02:28:14 for OpenCPN Partial API docs by
1.9.8