18 #ifndef __PONGASOFT_UTILS_CONCURRENT_CONCURRENT_H__ 19 #define __PONGASOFT_UTILS_CONCURRENT_CONCURRENT_H__ 27 namespace Concurrent {
71 Element(std::unique_ptr<T> iElement,
bool iNew) noexcept :
fElement{std::move(iElement)},
fNew{iNew} {}
106 std::unique_ptr<Element>
store(std::unique_ptr<Element> iElement)
108 iElement->fNew =
true;
110 return std::move(iElement);
124 std::unique_ptr<Element>
load(std::unique_ptr<Element> iElement)
126 iElement->fNew =
false;
128 return std::move(iElement);
135 std::unique_ptr<Element>
__newElement()
const {
return std::make_unique<Element>(std::move(
__newT()),
false); }
198 auto element =
pop();
230 auto element =
pop();
277 template<
class ElementModifier>
288 template<
class ElementModifier>
291 if(iElementModifier(
fPushValue->fElement.get()))
402 template<
class ElementModifier>
403 void update(ElementModifier
const &iElementModifier)
405 iElementModifier(
fSetValue->fElement.get());
413 template<
class ElementModifier>
414 bool updateIf(ElementModifier
const &iElementModifier)
416 if(iElementModifier(
fSetValue->fElement.get()))
436 namespace WithSpinLock {
456 bool iIsEmpty =
false) :
470 auto &spinLock = const_cast<SpinLock &>(
fSpinLock);
471 auto lock = spinLock.acquire();
614 #endif // __PONGASOFT_UTILS_CONCURRENT_CONCURRENT_H__ bool fIsEmpty
Definition: Concurrent.h:538
void push(T const *iElement)
Definition: Concurrent.h:267
Definition: SpinLock.h:32
void push(T const *iElement)
Definition: Concurrent.h:529
void get(T &oElement)
Definition: Concurrent.h:359
Definition: Concurrent.h:317
typename SingleElementStorage< pongasoft::VST::NormalizedState >::Element Element
Definition: Concurrent.h:305
Element(std::unique_ptr< T > iElement, bool iNew) noexcept
Definition: Concurrent.h:71
AtomicValue(std::unique_ptr< T > iValue)
Definition: Concurrent.h:551
SingleElementQueue()
Definition: Concurrent.h:152
void get(T *oElement)
Definition: Concurrent.h:579
std::unique_ptr< Element > fGetValue
Definition: Concurrent.h:428
Definition: Concurrent.h:548
bool updateIf(ElementModifier const &iElementModifier)
Definition: Concurrent.h:414
std::unique_ptr< T > fElement
Definition: Concurrent.h:73
bool __isLockFree() const
Definition: Concurrent.h:99
std::unique_ptr< Element > load(std::unique_ptr< Element > iElement)
Definition: Concurrent.h:124
T const * last() const
Definition: Concurrent.h:211
std::unique_ptr< Element > fPushValue
Definition: Concurrent.h:308
AtomicValue(std::unique_ptr< T > iValue)
Definition: Concurrent.h:321
bool isEmpty() const
Definition: Concurrent.h:90
void set(T const &iValue)
Definition: Concurrent.h:383
bool pop(T &oElement)
Definition: Concurrent.h:196
SingleElementStorage(std::unique_ptr< T > iElement, bool iIsEmpty) noexcept
Definition: Concurrent.h:79
SpinLock fSpinLock
Definition: Concurrent.h:605
Definition: Concurrent.h:69
T getCopy()
Definition: Concurrent.h:351
T get()
Definition: Concurrent.h:559
AtomicValue(T const &iValue)
Definition: Concurrent.h:553
void push(T const &iElement)
Definition: Concurrent.h:518
SingleElementQueue(std::unique_ptr< T > iFirstElement, bool iIsEmpty=false)
Definition: Concurrent.h:455
std::unique_ptr< T > __newT() const
Definition: Concurrent.h:132
void popOrLast(T &oElement)
Definition: Concurrent.h:242
bool updateAndPushIf(ElementModifier const &iElementModifier)
Definition: Concurrent.h:289
void pushValue()
Definition: Concurrent.h:299
std::unique_ptr< Element > store(std::unique_ptr< Element > iElement)
Definition: Concurrent.h:106
~SingleElementStorage()
Definition: Concurrent.h:84
void set(T const *iValue)
Definition: Concurrent.h:597
void push(T const &iElement)
Definition: Concurrent.h:258
std::unique_ptr< Element > fSetValue
Definition: Concurrent.h:429
std::unique_ptr< Element > __newElement() const
Definition: Concurrent.h:135
void updateAndPush(ElementModifier const &iElementModifier)
Definition: Concurrent.h:278
bool pop(T *oElement)
Definition: Concurrent.h:501
SingleElementQueue(std::unique_ptr< T > iElement, bool iIsEmpty=false)
Definition: Concurrent.h:160
std::unique_ptr< T > fSingleElement
Definition: Concurrent.h:537
Lock acquire()
Definition: SpinLock.h:74
T * pop()
Definition: Concurrent.h:177
bool fNew
Definition: Concurrent.h:74
bool pop(T &oElement)
Definition: Concurrent.h:482
T const * get()
Definition: Concurrent.h:338
void update(ElementModifier const &iElementModifier)
Definition: Concurrent.h:403
Definition: Concurrent.h:445
std::unique_ptr< T > fValue
Definition: Concurrent.h:604
SingleElementQueue()
Definition: Concurrent.h:448
SpinLock fSpinLock
Definition: Concurrent.h:539
void last(T &oElement) const
Definition: Concurrent.h:220
T const * popOrLast()
Definition: Concurrent.h:228
Definition: Concurrent.h:148
typename SingleElementStorage< pongasoft::VST::NormalizedState >::Element Element
Definition: Concurrent.h:426
void get(T &oElement)
Definition: Concurrent.h:569
std::unique_ptr< Element > fPopValue
Definition: Concurrent.h:307
void set(T const *iValue)
Definition: Concurrent.h:392
void get(T *oElement)
Definition: Concurrent.h:367
void set(T const &iValue)
Definition: Concurrent.h:588
bool isEmpty() const
Definition: Concurrent.h:468
Definition: Concurrent.h:65
std::atomic< Element * > fSingleElement
Definition: Concurrent.h:139