diff --git a/src/steam/engine/buffer-provider.cpp b/src/steam/engine/buffer-provider.cpp index 922c91fbe..c5d52812d 100644 --- a/src/steam/engine/buffer-provider.cpp +++ b/src/steam/engine/buffer-provider.cpp @@ -61,7 +61,13 @@ namespace engine { { return bool (bufferStage_->lookup (id)); } - + + bool + BufferProvider::isAllotted (HashVal id) const + { + return bufferStage_->isAllotted (id); + } + bool BufferProvider::isAccessible (HashVal id) const { @@ -256,6 +262,14 @@ namespace engine { and descriptor_.provider_->isAccessible (*this); } + bool + BuffHandle::isAllotted() const + { + ENSURE (descriptor_.provider_); + return bool(pBuffer_) + and descriptor_.provider_->isAllotted (*this); + } + size_t BuffDescr::buffSize() const @@ -299,7 +313,7 @@ namespace engine { { if (pBuffer_) { - REQUIRE (isValid()); + REQUIRE (isAllotted()); descriptor_.provider_->releaseBuffer(*this); pBuffer_ = 0; } diff --git a/src/steam/engine/buffer-provider.hpp b/src/steam/engine/buffer-provider.hpp index 073a32a0c..500250a09 100644 --- a/src/steam/engine/buffer-provider.hpp +++ b/src/steam/engine/buffer-provider.hpp @@ -176,6 +176,7 @@ namespace engine { /* === API for BuffHandle internal access === */ bool isValid (HashVal) const; + bool isAllotted (HashVal) const; bool isAccessible (HashVal) const; size_t getBufferSize (HashVal) const; @@ -208,6 +209,7 @@ namespace engine { virtual ID mark_released (HashVal stateKey) =0; virtual ID abandon (HashVal, bool destroy=false) =0; virtual void discard (HashVal stateKey) =0; + virtual bool isAllotted (HashVal stateKey) const =0; virtual bool isAccessible (HashVal stateKey) const =0; }; diff --git a/src/steam/engine/buffhandle.hpp b/src/steam/engine/buffhandle.hpp index fd9518e66..5dddec896 100644 --- a/src/steam/engine/buffhandle.hpp +++ b/src/steam/engine/buffhandle.hpp @@ -130,6 +130,7 @@ namespace engine { operator bool() const { return isValid(); } operator HashVal() const { return descriptor_; } + bool isAllotted() const; bool isValid() const; size_t size() const; @@ -178,7 +179,7 @@ namespace engine { inline BU& BuffHandle::accessAs() { - if (!pBuffer_) + if (not pBuffer_) throw error::Logic ("buffer not (yet) locked for access by clients" , LERR_(LIFECYCLE)); return *reinterpret_cast (pBuffer_); diff --git a/src/steam/engine/diagnostic-buffer-provider.cpp b/src/steam/engine/diagnostic-buffer-provider.cpp index b735f2d19..17f1c48eb 100644 --- a/src/steam/engine/diagnostic-buffer-provider.cpp +++ b/src/steam/engine/diagnostic-buffer-provider.cpp @@ -27,6 +27,7 @@ #include "steam/engine/diagnostic-buffer-provider.hpp" #include "steam/engine/heap-mem-buffer-store.hpp" #include "lib/format-string.hpp" +#include "lib/util-foreach.hpp" #include "lib/util.hpp" #include @@ -152,6 +153,12 @@ namespace engine { return stage_->lookup (key); } + bool + isAllotted (HashVal stateKey) const override + { + return stage_->isAllotted (stateKey); + } + bool isAccessible (HashVal stateKey) const override { @@ -257,7 +264,46 @@ namespace engine { // return dbp_.heapStore_.access_emitted(bufferID).accessMemory(); ///////////////////////////////////////TICKET 1410 : switch to newly defined tracking-API } - + bool + BufferDiagnostic::was_created (HashVal id) + { + return created.contains (id); + } + + bool + BufferDiagnostic::was_emitted (HashVal id) + { + return emitted.contains (id); + } + + bool + BufferDiagnostic::was_released (HashVal id) + { + return released.contains (id); + } + + bool + BufferDiagnostic::is_in_use (HashVal id) + { + return was_created (id) + and not (was_released (id) or was_emitted (id)); + } + + bool + BufferDiagnostic::was_used (HashVal id) + { + return was_created (id) + and was_released (id); + } + + bool + BufferDiagnostic::all_buffers_released() + { + return util::and_all (created.each() + ,[this](Block const& entry){ return released.contains(entry); } + ); + } + + - }} // namespace engine diff --git a/src/steam/engine/diagnostic-buffer-provider.hpp b/src/steam/engine/diagnostic-buffer-provider.hpp index e48432574..fe1d02988 100644 --- a/src/steam/engine/diagnostic-buffer-provider.hpp +++ b/src/steam/engine/diagnostic-buffer-provider.hpp @@ -25,6 +25,7 @@ #include "lib/util.hpp" #include "steam/engine/type-handler.hpp" ///////////////OOO warum? #include "steam/engine/naive-buffer-setup.hpp" +#include "lib/iter-adapter-stl.hpp" #include "lib/result.hpp" #include "lib/nocopy.hpp" @@ -55,6 +56,9 @@ namespace engine { Block (metadata::Key, Buff* mem); operator HashVal() const { return storage? stateKey:typeKey; } + + template + BU const& accessAs() const; }; @@ -70,11 +74,29 @@ namespace engine { Result operator[] (size_t seqNr) const; Result byHandle (HashVal handle) const; bool contains (HashVal handle) const; + auto each() const; size_t cnt() const; /* ========= Accounting API ========= */ void record (Block); }; + + + inline auto + StateReg::each() const + { + return lib::iter_stl::eachElm (reg_); + } + + template + inline BU const& + Block::accessAs() const + { + if (not storage) + throw error::Logic ("buffer was never actually locked for access by clients" + , LERR_(LIFECYCLE)); + return *reinterpret_cast (storage); + } }//(End)diagnostic descriptors. @@ -122,6 +144,11 @@ namespace engine { bool buffer_was_used (uint bufferID); ///< @deprecated ////////////////////////////////////////TICKET 1410 bool buffer_was_closed (uint bufferID); ///< @deprecated ////////////////////////////////////////TICKET 1410 void* accessMemory (uint bufferID); ///< @deprecated ////////////////////////////////////////TICKET 1410 + bool was_created (HashVal); + bool was_emitted (HashVal); + bool was_released (HashVal); + bool is_in_use (HashVal); + bool was_used (HashVal); bool all_buffers_released(); diagn::StateReg const& created; diagn::StateReg const& emitted; diff --git a/src/steam/engine/simple-buffer-state-registry.hpp b/src/steam/engine/simple-buffer-state-registry.hpp index 3fb91be6a..20a4e0985 100644 --- a/src/steam/engine/simple-buffer-state-registry.hpp +++ b/src/steam/engine/simple-buffer-state-registry.hpp @@ -57,6 +57,12 @@ namespace engine { : metadata::Key::INVALID; } + bool + isAllotted (HashVal stateKey) const override + { + return metadata_.isLocked (stateKey); + } + bool isAccessible (HashVal stateKey) const override { diff --git a/tests/core/steam/engine/diagnostic-buffer-provider-test.cpp b/tests/core/steam/engine/diagnostic-buffer-provider-test.cpp index 3f2a5693f..03ce31729 100644 --- a/tests/core/steam/engine/diagnostic-buffer-provider-test.cpp +++ b/tests/core/steam/engine/diagnostic-buffer-provider-test.cpp @@ -25,40 +25,17 @@ #include -namespace steam { +namespace steam { namespace engine{ namespace test { - namespace { // Test fixture const size_t TEST_ELM_SIZE = sizeof(uint); const uint MAX_ELMS = 50; std::vector testNumbers(MAX_ELMS); - - - bool - has_expectedContent (uint nr, diagn::Block& memoryBlock) - { -#if false //////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1410 : disabled code to disentangle BufferProvider implementation - void* mem = memoryBlock.accessMemory(); - uint data = *static_cast (mem); - - return data == testNumbers[nr]; -#endif /////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1410 : (end) disabled code - } - - bool - verifyUsedBlock (uint nr, diagn::Block& memoryBlock) - { -#if false //////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1410 : disabled code to disentangle BufferProvider implementation - return memoryBlock.was_used() - and memoryBlock.was_closed() - and has_expectedContent (nr, memoryBlock); -#endif /////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1410 : (end) disabled code - } } @@ -98,9 +75,6 @@ namespace test { provider.releaseBuffer(testBuff); CHECK (not testBuff); -SHOW_EXPR(watch(provider).created.cnt()) -SHOW_EXPR(watch(provider).emitted.cnt()) -SHOW_EXPR(watch(provider).released.cnt()) CHECK (1 == watch(provider).created.cnt()); CHECK (1 == watch(provider).emitted.cnt()); CHECK (1 == watch(provider).released.cnt()); @@ -129,7 +103,15 @@ SHOW_EXPR(watch(provider).released.cnt()) for (uint nr=0; nr()); + + auto id = HashVal(block); // that would also be the ID of the BuffHandle + CHECK (watch(provider).was_created (id)); + CHECK (watch(provider).was_released (id)); + CHECK (not watch(provider).is_in_use (id)); } } @@ -208,13 +190,20 @@ SHOW_EXPR(watch(provider).released.cnt()) // CHECK (!provider.access_emitted(3).was_closed()); // CHECK ( provider.access_emitted(4).was_closed()); - CHECK (!bu2); - CHECK (bu3); + CHECK (not bu2.isValid()); + CHECK (not bu3.isValid()); + CHECK (not bu2.isAllotted()); + CHECK ( bu3.isAllotted()); bu1.release(); bu3.release(); bu4.release(); + CHECK (not bu1.isAllotted()); + CHECK (not bu2.isAllotted()); + CHECK (not bu3.isAllotted()); + CHECK (not bu4.isAllotted()); + CHECK (not bu5.isAllotted()); // CHECK (5 == provider.emittedCnt()); ///////////////////////////////OOO provide suitable diagnostic API! } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index c395ae8a6..1e60dc579 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -111480,7 +111480,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -111488,8 +111488,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + + @@ -111628,7 +111629,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -111760,7 +111761,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -111804,7 +111805,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -112134,7 +112135,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + + @@ -112145,8 +112147,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - - + + @@ -112157,6 +112159,20 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + + + + + + + + + + @@ -112169,9 +112185,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + - + @@ -112871,11 +112887,11 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - - + + - - + + @@ -112894,12 +112910,14 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) ...und zwar, weil wir ein BuffHandle speichern wollen, das einen BufferProvider einschließt. Dazu brauchen wir die Rückreferenz auf den Provider. Und das darf eigentlich nur BufferProvider selber...

- -
+
+ + +
@@ -112959,15 +112977,71 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + +

+ Seit 2024 bin ich nun mehrfach durch den Kern der Implementierung durchgegangen, und konnte keine offensichtliche Lücke finden (nur ein paar lokale Inkonsistenzen, wie z.B. daß wir uns den aktuellen Buffer-Pointer im Entry speichern, obwohl es genügen würde, ihn nur in den Hash einzurechnen). Auch der Zugangs-Funktionen, BufferMetadata::key(...) sind konsistent und korrekt strukturiert: es gibe eine einzige Funktion, mit der man »aus dem Nichts« einsteigen kann (und in dieser Funktion hatte ich 2024 die Reihenfolge der Qualifizierungen in ein verbindliches Schema geordnet). Außerdem gibt es ein paar weitere Funktionen, mit denen man einen bereits bestehenden Key verfeinern kann, und eine Funktion, die verwendet wird, um daraus einen Entry zu machen. +

+

+ Solange ich mich also nicht aus dem zugrundeliegenden gedanklichen Schema löse, werde ich hier nichts Relevantes in Bewegung bringen können +

+ + +
+ +
+ + + + + + @@ -113126,7 +113200,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + + + @@ -113136,6 +113212,41 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + + + + + + + + + +

+ Inhaltlich ist sie redundant, denn Zustandsübergänge werden auch in den Metadaten geprüft. Jedoch ist die ganze Struktur relativ offen, und es gibt sogar die »Unschärfe«, daß u.U der Pointer im Handle nicht auf NULL gesetzt wird (hab das gestern durchdacht und bin zu dem Schluß gekommen, daß sich das nur um den Preis eines kompletten Umbaues beheben ließe, wozu ich keinen Anlaß sehe) +

+ + +
+
+
+ + + + + + +

+ ich halte dieses Prädikat für sinnvoller, als ein isEmitted(); es bedeutet, daß noch eine Allokation »dran hängt« +

+ +
+ +
+
@@ -113530,15 +113641,18 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
- - - + + + + + +
@@ -113647,9 +113761,34 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)

- + + + + + + + + + +

+ derzeit kann ich gar nix mehr ändern +

+ + +
+ + + + +
+ + + + + +