Add general purpose allocator to the framework

This commit is contained in:
Alex Harker
2019-08-12 15:47:26 +01:00
parent dfe6a8361b
commit 9521f321db
2 changed files with 23 additions and 1 deletions
+4 -1
View File
@@ -27,7 +27,7 @@ class FrameLib_DSP : public FrameLib_Block, public FrameLib_Queueable<FrameLib_D
using Queue = FrameLib_Queueable<FrameLib_Block>::Queue;
using LocalQueue = FrameLib_Queueable<FrameLib_DSP>::Queue;
using Serial = FrameLib_Parameters::Serial;
friend class FrameLib_ProcessingQueue;
protected:
@@ -96,6 +96,7 @@ private:
@brief a struct that represents an output frame.
*/
struct Output
{
Output() : mMemory(nullptr), mType(kFrameNormal), mCurrentType(kFrameNormal), mRequestedType(kFrameNormal), mCurrentSize(0), mRequestedSize(0), mPointerOffset(0) {}
@@ -113,6 +114,8 @@ private:
public:
using Allocator = FrameLib_Block::Allocator;
// Constructor / Destructor
FrameLib_DSP(ObjectType type, FrameLib_Context context, FrameLib_Proxy *proxy, FrameLib_Parameters::Info *info, unsigned long nIns, unsigned long nOuts, unsigned long nAudioChans = 0);
+19
View File
@@ -165,6 +165,25 @@ public:
using Queue = typename FrameLib_Queueable<T>::Queue;
using Connection = FrameLib_Connection<T, unsigned long>;
// An allocator that you can pass to other objects/code whilst this object exists
class Allocator
{
public:
Allocator(FrameLib_Object& object) : mObject(object) {}
template <class U>
U *allocate(size_t N) { return mObject.alloc<U>(N); }
template <class U>
void deallocate(U *& ptr) { mObject.dealloc(ptr); }
private:
FrameLib_Object &mObject;
};
private:
// A connector is a thing with one input and many outputs