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, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18
**************************************************************************/
19
25
#ifndef _PERIODIC_TIMER_H
26
#define _PERIODIC_TIMER_H
27
28
#include <atomic>
29
#include <chrono>
30
#include <condition_variable>
31
#include <memory>
32
#include <mutex>
33
#include <string>
34
#include <thread>
35
45
class
PeriodicTimer
{
46
public
:
47
PeriodicTimer
(std::chrono::milliseconds interval);
48
49
virtual
~PeriodicTimer
();
50
51
void
Stop();
52
53
protected
:
54
virtual
void
Notify() = 0;
55
56
private
:
57
const
std::chrono::milliseconds m_interval;
58
std::mutex m_mutex;
59
std::condition_variable m_cond_var;
60
std::atomic<int> m_run_sts;
// 1 == running, 0 == request stop, -1 == stopped
61
std::thread m_thread;
62
63
void
Worker
();
64
};
65
66
#endif
// PERIODIC_TIMER_H
PeriodicTimer
Continuously run Notify with given interval.
Definition
periodic_timer.h:45
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 Sat Mar 1 2025 02:28:51 for OpenCPN Partial API docs by
1.9.8