SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
Toggle main menu visibility
Loading...
Searching...
No Matches
scoped_lock.hpp
Go to the documentation of this file.
1
/*
2
* SatNOGS-COMMS MCU software
3
*
4
* Copyright (C) 2022-2023, Libre Space Foundation <http://libre.space>
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* SPDX-License-Identifier: GNU General Public License v3.0 or later
20
*/
21
22
#pragma once
23
24
#include <zephyr/kernel.h>
25
26
namespace
satnogs::comms
27
{
28
33
class
scoped_lock
34
{
35
public
:
41
scoped_lock
(
struct
k_mutex *mutex) : m_mtx(mutex)
42
{
43
k_mutex_lock(m_mtx, K_FOREVER);
44
}
45
51
scoped_lock
(
struct
k_mutex &mutex) : m_mtx(&mutex)
52
{
53
k_mutex_lock(m_mtx, K_FOREVER);
54
}
55
60
~scoped_lock
() { k_mutex_unlock(m_mtx); }
61
62
private
:
63
struct
k_mutex *m_mtx;
64
};
65
66
}
// namespace satnogs::comms
satnogs::comms::scoped_lock::~scoped_lock
~scoped_lock()
Upon destruction, the mutex is released.
Definition
scoped_lock.hpp:60
satnogs::comms::scoped_lock::scoped_lock
scoped_lock(struct k_mutex &mutex)
Creates a scoped lock.
Definition
scoped_lock.hpp:51
satnogs::comms::scoped_lock::scoped_lock
scoped_lock(struct k_mutex *mutex)
Creates a scoped lock.
Definition
scoped_lock.hpp:41
satnogs::comms
Definition
bsp.cpp:28
src
scoped_lock.hpp
Generated by
1.17.0