30#ifndef APF_SHAREDDATA_H
31#define APF_SHAREDDATA_H
44 explicit SharedData(CommandQueue& fifo, X&& def = X())
46 , _data(std::forward<X>(def))
50 const X& get()
const {
return _data; }
52 operator const X&()
const {
return this->get(); }
54 void operator=(
const X& rhs)
56 _fifo.push(
new SetCommand(&_data, rhs));
59 void operator=(X&& rhs)
61 _fifo.push(
new SetCommand(&_data, std::forward<X>(rhs)));
64 void set_from_rt_thread(X&& data)
66 _data = std::forward<X>(data);
70 operator==(
const SharedData& lhs,
const X& rhs) {
return lhs._data == rhs; }
72 operator==(
const X& lhs,
const SharedData& rhs) {
return lhs == rhs._data; }
74 operator!=(
const SharedData& lhs,
const X& rhs) {
return lhs._data != rhs; }
76 operator!=(
const X& lhs,
const SharedData& rhs) {
return lhs != rhs._data; }
84class SharedData<X>::SetCommand :
public CommandQueue::Command
87 SetCommand(X* pointer,
const X& data)
91 assert(pointer !=
nullptr);
94 SetCommand(X* pointer, X&& data)
96 , _data(std::forward<X>(data))
98 assert(pointer !=
nullptr);
102 virtual void execute()
105 swap(*_pointer, _data);
108 virtual void cleanup() {}
Audio Processing Framework.