YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
lock_base_interface.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// This file defines a generic and abstract C++
15// interface for a elementary, simple lock. This
16// interface is the basis for all mutexes, semaphores
17// or condition variables, and has to be implemented
18// by every platform.
19// It has to be made sure that locking/unlocking can
20// be performed from anywhere in the code (different
21// task etc.). Other classes like mutex will define
22// stronger constraints in this respect (e.g. a mutex
23// can only be locked/unlocked from the same task).
24
25#ifndef _LOCK_BASE_INTERFACE_H_
26#define _LOCK_BASE_INTERFACE_H_
27
29public:
30 // Try to lock. Return true on success.
31 virtual bool try_lock() = 0;
32
33 // Unlock lock
34 virtual void unlock() = 0;
35
36 // Status of lock
37 virtual bool is_locked() = 0;
38
39protected:
40 virtual ~lock_base_interface() = default;
41};
42
43#endif // _LOCK_BASE_INTERFACE_H_