BufferProvider: draft mapping of Stage API

This whole exercise is an attempt to make the whole implementation
clearer and more approachable — especially regarding the future extension
to a concurrency-hardened variant. The implementation is still backed
by a `BufferMetadata` table, and the rearranged code can be inlined.
This commit is contained in:
Fischlurch 2026-02-14 22:49:22 +01:00
parent 5518030a7d
commit 6f14046c0c
2 changed files with 54 additions and 4 deletions

View file

@ -181,23 +181,30 @@ namespace engine {
protected:
bool was_created_by_this_provider (BuffDescr const&) const;
using Buff = StreamType::ImplFacade::DataBuffer; ///< marker type for an actual data buffer
class BufferStage
: public BufferMetadata /////////////////////////////////////////////////////////////////////TICKET #1410 : mix-in exiting old implementation -- for sake of refactoring only!
{
protected:
using Key = metadata::Key;
using ID = metadata::Key const&;
public:
virtual ~BufferStage() { } ///< this is an interface
using BufferMetadata::BufferMetadata; ///////////////////////////////////////////////////////////TICKET #1410 : actual implementation structures should move down into this classes implementation
virtual ID lookup (HashVal) =0;
virtual ID mark_locked (ID typeKey, Buff*, LocalTag) =0;
virtual ID mark_emitted (HashVal stateKey) =0;
virtual ID mark_released (HashVal stateKey) =0;
virtual ID abandon (HashVal, bool destroy=false) =0;
virtual void discard (HashVal stateKey) =0;
};
class BufferStore
: util::NonCopyable
{
protected:
using Buff = StreamType::ImplFacade::DataBuffer; ///< marker type for an actual data buffer
using Slot = std::tuple<Buff*,LocalTag>;
public:
virtual ~BufferStore() { } ///< this is an interface

View file

@ -37,6 +37,7 @@ namespace engine {
namespace error = lumiera::error;
using metadata::Buff;
// using std::unique_ptr;
// using lib::HashVal;
@ -49,9 +50,51 @@ namespace engine {
: public BufferProviderSetup::Stage
{
///////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 1410 : rather hold BufferMetatdata object here
public:
/* === BufferStage interface === */
ID
lookup (HashVal key) override
{
return this->get (key);
}
ID
mark_locked (ID typeKey, Buff* storage, LocalTag implMark) override
{
return this->markLocked (typeKey, storage, implMark);
}
ID
mark_emitted (HashVal stateKey) override
{
metadata::Entry& metaEntry = this->get (stateKey);
metaEntry.mark(EMITTED);
return metaEntry; // contains also the key
}
ID
mark_released (HashVal stateKey) override
{
metadata::Entry& metaEntry = this->get (stateKey);
metaEntry.mark(FREE); // might invoke embedded dtor function
return metaEntry;
}
ID
abandon (HashVal stateKey, bool invokeDtor) override
{
metadata::Entry& metaEntry = this->get (stateKey);
metaEntry.invalidate (invokeDtor);
return metaEntry;
}
void
discard (HashVal stateKey) override
{
this->release (stateKey);
}
public:
SimpleBufferStateRegistry (Literal implementationID)