summaryrefslogtreecommitdiffstats
path: root/src/engine/BufferFactory.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-01-05 03:51:50 +0000
committerDavid Robillard <d@drobilla.net>2010-01-05 03:51:50 +0000
commitc67392abf59b500fe405101d7ad896d9da869e47 (patch)
tree53b5d5b27d4389caa123c5deb2a1e0aadf180ec7 /src/engine/BufferFactory.hpp
parent4c32f20699db0ede850a9485271dfda779761fac (diff)
downloadingen-c67392abf59b500fe405101d7ad896d9da869e47.tar.gz
ingen-c67392abf59b500fe405101d7ad896d9da869e47.tar.bz2
ingen-c67392abf59b500fe405101d7ad896d9da869e47.zip
Realtime safe buffer reference handling.
Turns out that dropping a shared_ptr is not realtime safe, even if you use a realtime safe deleter. Instead, instrusive_ptr is used for buffer references, so a buffer reference may safely be dropped in the audio thread (in which case it will be recycled by the BufferFactory). Faster, cleaner, better. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2341 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/BufferFactory.hpp')
-rw-r--r--src/engine/BufferFactory.hpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/engine/BufferFactory.hpp b/src/engine/BufferFactory.hpp
index d6e0b70c..8fddb70f 100644
--- a/src/engine/BufferFactory.hpp
+++ b/src/engine/BufferFactory.hpp
@@ -19,6 +19,7 @@
#define BUFFER_FACTORY_H
#include <map>
+#include <boost/intrusive_ptr.hpp>
#include "interface/PortType.hpp"
#include "glibmm/thread.h"
#include "raul/RingBuffer.hpp"
@@ -29,6 +30,7 @@ namespace Ingen {
using namespace Shared;
class Engine;
+class Buffer;
namespace Shared { class LV2URIMap; }
@@ -36,13 +38,16 @@ class BufferFactory {
public:
BufferFactory(Engine& engine, SharedPtr<Shared::LV2URIMap> map);
- SharedPtr<Buffer> get(Shared::PortType type, size_t size=0, bool force_create=false);
+ typedef boost::intrusive_ptr<Buffer> Ref;
+
+ Ref get(Shared::PortType type, size_t size=0, bool force_create=false);
private:
friend class BufferDeleter;
+ friend class Buffer;
void recycle(Buffer* buf);
- SharedPtr<Buffer> create(Shared::PortType type, size_t size=0);
+ Ref create(Shared::PortType type, size_t size=0);
inline Raul::AtomicPtr<Buffer>& free_list(Shared::PortType type) {
switch (type.symbol()) {