YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
src
task
lock_guard.h
1
// ---------------------------------------------
2
// This file is part of
3
// _ _ __ _ _ __ __
4
// ( \/ ) /__\ ( )_( ) /__\ ( )
5
// \ / /(__)\ ) _ ( /(__)\ )(__
6
// (__)(__)(__)(_) (_)(__)(__)(____)
7
//
8
// Yet Another HW Abstraction Library
9
// Copyright (C) Andreas Terstegge
10
// BSD Licensed (see file LICENSE)
11
//
12
// ---------------------------------------------
13
//
14
// Simple lock_guard implementation
15
//
16
#ifndef _LOCK_GUARD_H_
17
#define _LOCK_GUARD_H_
18
19
#include "mutex_interface.h"
20
21
class
lock_guard
{
22
public
:
23
lock_guard
(
mutex_interface
&
mutex
) : _mutex(
mutex
) {
24
_mutex.lock();
25
}
26
~lock_guard
() {
27
_mutex.unlock();
28
}
29
30
// No copy, no assignment
31
lock_guard
(
const
lock_guard
&) =
delete
;
32
lock_guard
& operator= (
const
lock_guard
&) =
delete
;
33
34
private
:
35
mutex_interface
& _mutex;
36
};
37
38
#endif
// _LOCK_GUARD_H_
lock_guard
Definition
lock_guard.h:21
mutex_interface
Definition
mutex_interface.h:46
mutex
Definition
mutex.h:27
Generated by
1.12.0