YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
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
22public:
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
34private:
35 mutex_interface & _mutex;
36};
37
38#endif // _LOCK_GUARD_H_
Definition mutex.h:27