Add general purpose allocator to the framework
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user