NOVA
Stripped down NOVA kernel for the OSY course
Loading...
Searching...
No Matches
include
lock_guard.h
1
/*
2
* Generic Lock Guard
3
*
4
* Copyright (C) 2009-2011 Udo Steinberg <udo@hypervisor.org>
5
* Economic rights: Technische Universitaet Dresden (Germany)
6
*
7
* This file is part of the NOVA microhypervisor.
8
*
9
* NOVA is free software: you can redistribute it and/or modify it
10
* under the terms of the GNU General Public License version 2 as
11
* published by the Free Software Foundation.
12
*
13
* NOVA is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License version 2 for more details.
17
*/
18
19
#pragma once
20
21
#include "compiler.h"
22
23
template
<
typename
T>
24
class
Lock_guard
25
{
26
private
:
27
T &_lock;
28
29
public
:
30
ALWAYS_INLINE
31
inline
Lock_guard (T &l) : _lock (l)
32
{
33
_lock.lock();
34
}
35
36
ALWAYS_INLINE
37
inline
~Lock_guard()
38
{
39
_lock.unlock();
40
}
41
};
Generated by
1.14.0