blob: 9ad4e20feaccc84603f00bdcec159a2679b3e138 (
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 <mutex>
#include <memory>
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();
};
|