diff --git a/src/steam/engine/buffer-metadata.hpp b/src/steam/engine/buffer-metadata.hpp index d4bcca3b5..62420e12e 100644 --- a/src/steam/engine/buffer-metadata.hpp +++ b/src/steam/engine/buffer-metadata.hpp @@ -149,6 +149,10 @@ namespace engine { public: + /** Generic marker for an impossible / rejected type */ + static const Key INVALID; + + /** build a standard basic key describing a kind of Buffer. * @param familyID basic hash seed value to distinguish * families of buffer types managed by @@ -237,6 +241,19 @@ namespace engine { HashVal parentKey() const { return parent_;} operator HashVal() const { return hashID_;} + + friend bool + operator== (Key const& k1, Key const& k2) + { + return k1.hashID_ == k2.hashID_ + and k1.parent_ == k2.parent_; + } + + explicit + operator bool() const + { + return *this != INVALID; + } }; diff --git a/src/steam/engine/buffer-provider.cpp b/src/steam/engine/buffer-provider.cpp index 7f2766b6f..da3307565 100644 --- a/src/steam/engine/buffer-provider.cpp +++ b/src/steam/engine/buffer-provider.cpp @@ -31,7 +31,7 @@ namespace engine { // storage for the default-marker constants const TypeHandler TypeHandler::RAW{}; const LocalTag LocalTag::UNKNOWN{}; - const metadata::Key SimpleBufferStateRegistry::NULL_KEY{HashVal(0), size_t(0)}; //////OOO try to make this init into a constexpr and then do it in-class! + const metadata::Key metadata::Key::INVALID{HashVal(0), size_t(0)}; //////OOO consider to relocate those marker constants to somewhere more obvious namespace { // impl. details and definitions @@ -51,11 +51,19 @@ namespace engine { * currently locked and usable by client code */ bool - BufferProvider::verifyValidity (BuffDescr const& bufferID) const + BufferProvider::verifyValidity (HashVal id) const { - return bufferStage_->isLocked (bufferID); + return bool (bufferStage_->lookup (id)); } + size_t + BufferProvider::getBufferSize (HashVal id) const + { + auto& key = bufferStage_->lookup (id); + return key.storageSize(); + } + + BuffDescr BufferProvider::getDescriptorFor (size_t storageSize) @@ -73,14 +81,6 @@ namespace engine { } - size_t - BufferProvider::getBufferSize (HashVal typeID) const - { - auto& typeKey = bufferStage_->lookup (typeID); - return typeKey.storageSize(); - } - - /** BufferProvider API: declare in advance the need for working buffers. * This optional call allows client code to ensure the availability of the * necessary working space, prior to starting the actual operations. The @@ -132,7 +132,7 @@ namespace engine { auto& stateKey = bufferStage_->mark_locked (typeKey, storage, localTag); return BuffHandle (BuffDescr(*this, HashVal(stateKey)), storage); - } + } // NOTE: not the underlying parent descriptor! /** BufferProvider API: state transition to \em emitted state. @@ -205,11 +205,35 @@ namespace engine { /* === BuffDescr and BuffHandle === */ + /** + * A Buffer Descriptor is considered _valid_ + * iff it represents a registered buffer type. + * @note this implies that the buffer size is not zero. + */ bool - BuffDescr::verifyValidity() const + BuffDescr::isValid() const { ENSURE (provider_); - return provider_->verifyValidity(*this); + return provider_->verifyValidity (*this); + } + + /** + * A concrete Buffer Handle is considered valid, + * iff it is currently registered in the buffer metadata table. + * @note this implies also that it is in some active state, and + * indirectly (due to the _Buffer Provider Protocol_) also + * that the _parent type_ is valid, which means that it was + * created from a valid BuffDescr. But note that we can not + * see this parent type without lookup by the BufferProvider; + * The embedded #descriptor_ is synthetic, and reflects the + * handle's _state-key_ (⟶ registry Entry) not the type-key. + */ + bool + BuffHandle::isValid() const + { + ENSURE (descriptor_.provider_); + return bool(pBuffer_) + and descriptor_.provider_->verifyValidity (*this); } @@ -220,6 +244,11 @@ namespace engine { return provider_->getBufferSize (*this); } + size_t + BuffHandle::size() const + { + return descriptor_.buffSize(); + } uint BuffDescr::announce (uint count) diff --git a/src/steam/engine/buffhandle.hpp b/src/steam/engine/buffhandle.hpp index edd5a9215..df35af116 100644 --- a/src/steam/engine/buffhandle.hpp +++ b/src/steam/engine/buffhandle.hpp @@ -91,7 +91,7 @@ namespace engine { public: // using standard copy operations - bool verifyValidity() const; + bool isValid() const; size_t buffSize() const; operator HashVal() const { return subClassification_; } @@ -126,16 +126,17 @@ namespace engine { // using standard copy operations - explicit operator bool() const { return isValid(); } + explicit + operator bool() const { return isValid(); } + operator HashVal() const { return descriptor_; } + + bool isValid() const; + size_t size() const; void emit(); void release(); - - template - BU& create(); /////////////////////TICKET #1410 : this API needs to be retracted; it does not fit into the concept! - template BU& accessAs(); @@ -146,21 +147,6 @@ namespace engine { return pBuffer_; } - operator HashVal() const { return descriptor_; } - - bool - isValid() const - { - return bool(pBuffer_) - and descriptor_.verifyValidity(); - } - - size_t - size() const - { - return descriptor_.buffSize(); - } - private: void emergencyCleanup(); }; diff --git a/src/steam/engine/simple-buffer-state-registry.hpp b/src/steam/engine/simple-buffer-state-registry.hpp index 039c3091c..7810c25bf 100644 --- a/src/steam/engine/simple-buffer-state-registry.hpp +++ b/src/steam/engine/simple-buffer-state-registry.hpp @@ -50,7 +50,6 @@ namespace engine { : public BufferProviderSetup::Stage { ///////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 1410 : rather hold BufferMetatdata object here - static const metadata::Key NULL_KEY; ////////////////////////////OOO better init directly here as constexpr (to keep it really an implementation detail) /* === BufferStage interface === */ @@ -58,7 +57,7 @@ namespace engine { lookup (HashVal key) override { return this->isKnown(key)? this->get (key) - : NULL_KEY; + : metadata::Key::INVALID; } ID diff --git a/tests/core/steam/engine/buffer-provider-protocol-test.cpp b/tests/core/steam/engine/buffer-provider-protocol-test.cpp index afc66d19f..a551d5481 100644 --- a/tests/core/steam/engine/buffer-provider-protocol-test.cpp +++ b/tests/core/steam/engine/buffer-provider-protocol-test.cpp @@ -126,9 +126,9 @@ namespace test { BuffDescr desc1 = provider.getDescriptor(); BuffDescr desc2 = provider.getDescriptor(); // note: implies also sizeof(TestFrame) BuffDescr desc3 = provider.getDescriptorFor(BUFFSIZ); // Can also request fixed sized raw storage. -// CHECK (desc1.verifyValidity()); /////////////////////////////////////////////////////////////////////////////OOO fails (which is wrong) -// CHECK (desc2.verifyValidity()); -// CHECK (desc3.verifyValidity()); + CHECK (desc1.isValid()); + CHECK (desc2.isValid()); + CHECK (desc3.isValid()); uint num1 = desc1.announce(TEST_ELMS); uint num2 = desc1.announce(TEST_ELMS + 1); @@ -171,6 +171,7 @@ namespace test { CHECK (workBuff.isValid()); auto endSum = workBuff.accessAs().getChecksum(); workBuff.release(); // note: not every buffer need be emitted. + CHECK (!workBuff); auto diagnostic = watch(provider); CHECK (diagnostic.buffer_was_used (0)); diff --git a/tests/core/steam/engine/diagnostic-buffer-provider-test.cpp b/tests/core/steam/engine/diagnostic-buffer-provider-test.cpp index 445001f6f..3f2a5693f 100644 --- a/tests/core/steam/engine/diagnostic-buffer-provider-test.cpp +++ b/tests/core/steam/engine/diagnostic-buffer-provider-test.cpp @@ -97,6 +97,7 @@ namespace test { provider.emitBuffer (testBuff); provider.releaseBuffer(testBuff); + CHECK (not testBuff); SHOW_EXPR(watch(provider).created.cnt()) SHOW_EXPR(watch(provider).emitted.cnt()) SHOW_EXPR(watch(provider).released.cnt()) diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 22a2f057d..4fcdc1ac6 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -112871,6 +112871,17 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + + + + + + + @@ -112898,8 +112909,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -112930,13 +112941,20 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + - - - - + + + + + + + + + + +