diff --git a/src/steam/engine/buffer-provider.cpp b/src/steam/engine/buffer-provider.cpp index dd7883799..e4c1d4f5c 100644 --- a/src/steam/engine/buffer-provider.cpp +++ b/src/steam/engine/buffer-provider.cpp @@ -138,10 +138,10 @@ namespace engine { BufferProvider::lockBuffer (BuffDescr const& type) { REQUIRE (was_created_by_this_provider (type)); - size_t buffSiz = getBufferSize (type); - LocalTag implMarker; - Buff& storage = bufferStore_->provideBuffer (buffSiz, type, implMarker); - return buildHandle (type, &storage, implMarker); + metadata::Entry& metaEntry = bufferStage_->get (type); + size_t buffSiz = metaEntry.storageSize(); + auto [storage, implMarker] = bufferStore_->provideBuffer (buffSiz, type, metaEntry.localTag()); + return buildHandle (type, storage, implMarker); } @@ -181,7 +181,8 @@ namespace engine { metadata::Entry& metaEntry = bufferStage_->get (handle.entryID()); size_t buffSiz = metaEntry.storageSize(); metaEntry.mark(FREE); // might invoke embedded dtor function - bufferStore_->detachBuffer (buffSiz, metaEntry.parentKey(), metaEntry.localTag(), *handle); + bufferStore_->detachBuffer (buffSiz, metaEntry.parentKey() + ,std::make_tuple (handle.rawStorage(), metaEntry.localTag())); bufferStage_->release (metaEntry); } ERROR_LOG_AND_IGNORE (engine, "releasing a buffer from BufferProvider") @@ -226,7 +227,8 @@ namespace engine { metadata::Entry& metaEntry = bufferStage_->get (target.entryID()); size_t buffSiz = metaEntry.storageSize(); metaEntry.invalidate (invokeDtor); - bufferStore_->detachBuffer (buffSiz, metaEntry.parentKey(), metaEntry.localTag(), *target); + bufferStore_->detachBuffer (buffSiz, metaEntry.parentKey() + ,std::make_tuple (target.rawStorage(), metaEntry.localTag())); bufferStage_->release (metaEntry); } ERROR_LOG_AND_IGNORE (engine, "cleanup of buffer metadata while handling an error") diff --git a/src/steam/engine/buffer-provider.hpp b/src/steam/engine/buffer-provider.hpp index 4261a94e1..81832018d 100644 --- a/src/steam/engine/buffer-provider.hpp +++ b/src/steam/engine/buffer-provider.hpp @@ -112,6 +112,7 @@ #include #include +#include namespace steam { @@ -200,13 +201,15 @@ namespace engine { class BufferStore : util::NonCopyable { + protected: + using Slot = std::tuple; public: virtual ~BufferStore() { } ///< this is an interface - virtual uint prepareBuffers (uint cnt, size_t,HashVal typeID) =0; - virtual Buff& provideBuffer (size_t,HashVal typeID, LocalTag&) =0; - virtual void mark_emitted (size_t,HashVal, LocalTag const&) =0; - virtual void detachBuffer (size_t,HashVal, LocalTag, Buff&) =0; + virtual uint prepareBuffers (uint cnt, size_t,HashVal typeID) =0; + virtual Slot provideBuffer (size_t,HashVal typeID, LocalTag) =0; + virtual void mark_emitted (size_t,HashVal, LocalTag const&) =0; + virtual void detachBuffer (size_t,HashVal, Slot alloc) =0; }; unique_ptr bufferStage_; ///////////////////////////////////////////////////////////TICKET #1410 : must be turned into an internal interface diff --git a/src/steam/engine/buffhandle.hpp b/src/steam/engine/buffhandle.hpp index 6dc6477ac..43f1955a3 100644 --- a/src/steam/engine/buffhandle.hpp +++ b/src/steam/engine/buffhandle.hpp @@ -141,14 +141,11 @@ namespace engine { template BU& accessAs(); - - //////////////////////////////////////////TICKET #249 this operator looks obsolete. The Buff type is a placeholder type, - //////////////////////////////////////////TODO it should never be accessed directly from within Lumiera engine code - Buff& - operator* () const + Buff* + rawStorage() const { ENSURE (pBuffer_); - return *pBuffer_; + return pBuffer_; } operator HashVal() const { return descriptor_; } diff --git a/src/steam/engine/heap-mem-buffer-store.cpp b/src/steam/engine/heap-mem-buffer-store.cpp index 2cd66fe32..386f3d7e4 100644 --- a/src/steam/engine/heap-mem-buffer-store.cpp +++ b/src/steam/engine/heap-mem-buffer-store.cpp @@ -288,13 +288,13 @@ namespace engine { } - Buff& - HeapMemProvider::provideBuffer (size_t buffSiz, HashVal typeID, LocalTag&) + BufferProviderSetup::Store::Slot + HeapMemProvider::provideBuffer (size_t buffSiz, HashVal typeID, LocalTag) { BlockPool& blocks = getBlockPoolFor (buffSiz, typeID); Block& newBlock = blocks.createBlock(); LocalTag specifics{&newBlock}; // used by this implementation to find the storage to release later - return * asBuffer(newBlock.accessMemory()); + return std::make_tuple (asBuffer(newBlock.accessMemory()), specifics); } @@ -320,8 +320,9 @@ namespace engine { /** mark a buffer as officially discarded */ void - HeapMemProvider::detachBuffer (size_t buffSiz, HashVal typeID, LocalTag specifics, Buff& storage) + HeapMemProvider::detachBuffer (size_t buffSiz, HashVal typeID, Slot alloc) { + auto& [storage, specifics] = alloc; Block* block4buffer = locateBlock (buffSiz, typeID, specifics); REQUIRE (block4buffer, "releasing a buffer not allocated through this provider"); REQUIRE (util::isSameAdr (storage, block4buffer->accessMemory())); diff --git a/src/steam/engine/heap-mem-buffer-store.hpp b/src/steam/engine/heap-mem-buffer-store.hpp index 18272f24e..9c277738d 100644 --- a/src/steam/engine/heap-mem-buffer-store.hpp +++ b/src/steam/engine/heap-mem-buffer-store.hpp @@ -84,9 +84,9 @@ namespace engine { /* === BufferStore interface === */ virtual uint prepareBuffers (uint cnt, size_t,HashVal typeID) override; - virtual Buff& provideBuffer (size_t,HashVal, LocalTag&) override; - virtual void mark_emitted (size_t,HashVal, LocalTag const&) override; - virtual void detachBuffer (size_t,HashVal, LocalTag, Buff&) override; + virtual Slot provideBuffer (size_t,HashVal, LocalTag) override; + virtual void mark_emitted (size_t,HashVal, LocalTag const&) override; + virtual void detachBuffer (size_t,HashVal, Slot alloc) override; public: ~HeapMemProvider(); diff --git a/tests/core/steam/engine/node-base-test.cpp b/tests/core/steam/engine/node-base-test.cpp index e8a8be806..04e8f7788 100644 --- a/tests/core/steam/engine/node-base-test.cpp +++ b/tests/core/steam/engine/node-base-test.cpp @@ -257,7 +257,7 @@ namespace test { CHECK (m1.outBuff[0].accessAs() == -55); m1.connect(); // instruct the manifold to connect buffers to arguments - CHECK (isSameAdr (m1.outArgs, *buff)); + CHECK (isSameAdr (m1.outArgs, buff.rawStorage())); CHECK (*m1.outArgs == -55); m1.invoke(); // invoke the adapted processing function (fun_singleOut) @@ -295,8 +295,8 @@ namespace test { // connect arguments to buffers m2.connect(); - CHECK (isSameAdr (m2.inArgs, *buff)); - CHECK (isSameAdr (m2.outArgs, *buffOut)); + CHECK (isSameAdr (m2.inArgs, buff.rawStorage())); + CHECK (isSameAdr (m2.outArgs, buffOut.rawStorage())); CHECK (*m2.outArgs == -55); ////////////////////////////////OOO should be -99 m2.invoke(); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index bbee40bd1..7731ba498 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -111868,8 +111868,11 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + + + + @@ -112690,6 +112693,17 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + + + + + + +