Compare commits
4 Commits
cb350408e3
...
071f9e22be
Author | SHA1 | Date | |
---|---|---|---|
071f9e22be | |||
c274f35265 | |||
b732d73eb9 | |||
7362dc3503 |
@ -25,6 +25,7 @@ target_sources(nf7_core
|
||||
uv/parallelism.hh
|
||||
clock.hh
|
||||
logger.hh
|
||||
mutex.hh
|
||||
version.hh
|
||||
)
|
||||
|
||||
|
17
core/mutex.hh
Normal file
17
core/mutex.hh
Normal file
@ -0,0 +1,17 @@
|
||||
// No copyright
|
||||
#pragma once
|
||||
|
||||
#include "iface/common/mutex.hh"
|
||||
#include "iface/data/wrap.hh"
|
||||
|
||||
namespace nf7::core {
|
||||
|
||||
class Mutex : public data::Wrap<nf7::Mutex> {
|
||||
public:
|
||||
Mutex() : Wrap("nf7::core::Mutex", mtx_) { }
|
||||
|
||||
private:
|
||||
nf7::Mutex mtx_;
|
||||
};
|
||||
|
||||
} // namespace nf7::core
|
@ -21,6 +21,7 @@ target_sources(nf7_iface
|
||||
common/task_context.hh
|
||||
common/value.hh
|
||||
data/interface.hh
|
||||
data/wrap.hh
|
||||
subsys/concurrency.hh
|
||||
subsys/interface.hh
|
||||
subsys/logger.hh
|
||||
|
@ -20,10 +20,10 @@ class Mutex final {
|
||||
Mutex();
|
||||
~Mutex() noexcept;
|
||||
|
||||
Mutex(const Mutex&) = delete;
|
||||
Mutex(Mutex&&) = delete;
|
||||
Mutex& operator=(const Mutex&) = delete;
|
||||
Mutex& operator=(Mutex&&) = delete;
|
||||
Mutex(const Mutex&) = default;
|
||||
Mutex(Mutex&&) = default;
|
||||
Mutex& operator=(const Mutex&) = default;
|
||||
Mutex& operator=(Mutex&&) = default;
|
||||
|
||||
public:
|
||||
Future<SharedToken> Lock() noexcept;
|
||||
|
21
iface/data/wrap.hh
Normal file
21
iface/data/wrap.hh
Normal file
@ -0,0 +1,21 @@
|
||||
// No copyright
|
||||
#pragma once
|
||||
|
||||
#include "iface/data/interface.hh"
|
||||
|
||||
namespace nf7::data {
|
||||
|
||||
template <typename T>
|
||||
class Wrap : public Interface {
|
||||
protected:
|
||||
Wrap(const char* name, T& data) noexcept
|
||||
: Interface(name), data_(data) { }
|
||||
|
||||
public:
|
||||
T& data() const noexcept { return data_; }
|
||||
|
||||
private:
|
||||
T& data_;
|
||||
};
|
||||
|
||||
} // namespace nf7::data
|
@ -6,20 +6,6 @@
|
||||
|
||||
namespace nf7 {
|
||||
|
||||
class File : public Container<data::Interface> {
|
||||
public:
|
||||
File() = default;
|
||||
|
||||
public:
|
||||
Mutex& mtx() const noexcept { return mtx_; }
|
||||
|
||||
public:
|
||||
using Container<data::Interface>::Get;
|
||||
using Container<data::Interface>::GetOr;
|
||||
using Container<data::Interface>::installed;
|
||||
|
||||
private:
|
||||
mutable Mutex mtx_;
|
||||
};
|
||||
using File = Container<data::Interface>;
|
||||
|
||||
} // namespace nf7
|
||||
|
Loading…
x
Reference in New Issue
Block a user