blob: 55ddb0baf9df618580949bc7d4fd8c01d9d4c0bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#pragma once
#include <boost/noncopyable.hpp>
#include <memory>
#include <mutex>
class spi_lock : public boost::noncopyable
{
public:
using sptr = std::shared_ptr<spi_lock>;
static sptr make(uint8_t spidev_index);
spi_lock(uint8_t spidev_index);
uint8_t get_spidev() const;
private:
const uint8_t spidev_index;
// BasicLockable implementation for lock_guard
mutable std::mutex spi_mutex;
friend class std::lock_guard<spi_lock>;
void lock();
void unlock();
};
|