draft test to simulate a complete buffer metadata usage cycle
This commit is contained in:
parent
1772659a00
commit
991eec8185
6 changed files with 101 additions and 16 deletions
|
|
@ -479,22 +479,20 @@ namespace engine {
|
|||
|
||||
/** create a sub-type, using a different type/handler functor */
|
||||
Key
|
||||
key (HashVal parentKey, TypeHandler const& instanceFunc)
|
||||
key (Key const& parentKey, TypeHandler const& instanceFunc)
|
||||
{
|
||||
Key parentEntry (get (parentKey));
|
||||
return trackKey (parentEntry, instanceFunc);
|
||||
return trackKey (parentKey, instanceFunc);
|
||||
}
|
||||
|
||||
/** create a sub-type, using a different private-ID (implementation defined) */
|
||||
Key
|
||||
key (HashVal parentKey, LocalKey specifics)
|
||||
key (Key const& parentKey, LocalKey specifics)
|
||||
{
|
||||
Key parentEntry (get (parentKey));
|
||||
return trackKey (parentEntry, specifics);
|
||||
return trackKey (parentKey, specifics);
|
||||
}
|
||||
|
||||
Key
|
||||
key (HashVal parentKey, const void* concreteBuffer)
|
||||
key (Key const& parentKey, const void* concreteBuffer)
|
||||
{
|
||||
UNIMPLEMENTED ("create sub-object key for concrete buffer");
|
||||
}
|
||||
|
|
@ -526,7 +524,7 @@ namespace engine {
|
|||
|
||||
/* == memory management == */
|
||||
|
||||
Entry& markLocked (HashVal parentKey, const void* buffer);
|
||||
Entry& markLocked (Key const& parentKey, const void* buffer);
|
||||
void release (HashVal key);
|
||||
|
||||
private:
|
||||
|
|
@ -558,7 +556,7 @@ namespace engine {
|
|||
|
||||
/** */
|
||||
inline Metadata::Entry&
|
||||
Metadata::markLocked (HashVal parentKey, const void* buffer)
|
||||
Metadata::markLocked (Key const& parentKey, const void* buffer)
|
||||
{
|
||||
UNIMPLEMENTED ("transition to locked state");
|
||||
if (!buffer)
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ namespace engine {
|
|||
* For each kind of buffer, there is somewhere a BufferProvider responsible for the
|
||||
* actual storage management. This provider may "lock" a buffer for actual use,
|
||||
* returning a BuffHandle.
|
||||
* @note this descriptor and especially the #subClassification_ is really owned
|
||||
* by the BufferProvider, which may use (and even change) the opaque contents
|
||||
* to organise the internal buffer management.
|
||||
*
|
||||
* @todo try to move that definition into buffer-provider.hpp ////////////////////////////////////TICKET #249
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace test {
|
|||
|
||||
|
||||
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #833
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #852
|
||||
void*
|
||||
detect_start_level (BuffTableStorage& sto)
|
||||
{
|
||||
|
|
@ -117,7 +117,7 @@ namespace test {
|
|||
&& (not_within(b.inHandle, b.outBuff, &b.inBuff[num.nrO]))
|
||||
;
|
||||
}
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #833
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #852
|
||||
} // (End) internal defs
|
||||
|
||||
|
||||
|
|
@ -144,9 +144,9 @@ namespace test {
|
|||
// allocate storage block to be used chunk wise
|
||||
pStorage.reset (new BuffTableStorage (TABLE_SIZ));
|
||||
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #833
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #852
|
||||
invocation (0, detect_start_level(*pStorage));
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #833
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #852
|
||||
|
||||
pStorage.reset(0); // dtor throws assertion error if corrupted
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
//#include "proc/engine/testframe.hpp"
|
||||
//#include "proc/engine/diagnostic-buffer-provider.hpp"
|
||||
#include "proc/engine/buffer-metadata.hpp"
|
||||
#include "proc/engine/testframe.hpp"
|
||||
//#include "proc/engine/buffhandle.hpp"
|
||||
//#include "proc/engine/bufftable.hpp"
|
||||
|
||||
|
|
@ -184,9 +185,92 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** @test simulate a standard buffer provider usage cycle
|
||||
* @note to get the big picture, please refer to
|
||||
* BufferProviderProtocol_test#verifyStandardCase()
|
||||
* This testcase here performs precisely the metadata related
|
||||
* operations necessary to carry out the standard case outlined
|
||||
* in that more high level test.
|
||||
*/
|
||||
void
|
||||
verifyStandardCase()
|
||||
{
|
||||
// to build a descriptor for a buffer holding a TestFrame
|
||||
TypeHandler attachTestFrame = TypeHandler::create<TestFrame>();
|
||||
Metadata::Key bufferType1 = meta_->key(sizeof(TestFrame), attachTestFrame);
|
||||
|
||||
// to build a descriptor for a raw buffer of size SIZE_B
|
||||
Metadata::Key rawBuffType = meta_->key(SIZE_B);
|
||||
|
||||
// to announce using a number of buffers of this type
|
||||
LocalKey transaction1(1);
|
||||
LocalKey transaction2(2);
|
||||
bufferType1 = meta_->key(bufferType1, transaction1);
|
||||
rawBuffType = meta_->key(rawBuffType, transaction2);
|
||||
// these type keys are now handed over to the client,
|
||||
// embedded into a BufferDescriptor...
|
||||
|
||||
// later, when it comes to actually *locking* those buffers...
|
||||
typedef char RawBuffer[SIZE_B];
|
||||
|
||||
// do the necessary memory allocations behind the scenes
|
||||
TestFrame* frames = new TestFrame[3];
|
||||
RawBuffer* rawbuf = new RawBuffer[2]; // coding explicit allocations here for sake of clarity;
|
||||
// a real-world BufferProvider would use some kind of allocator
|
||||
|
||||
// track individual buffers by metadata entries
|
||||
Metadata::Entry f0 = meta_->markLocked(bufferType1, &frames[0]);
|
||||
Metadata::Entry f1 = meta_->markLocked(bufferType1, &frames[1]);
|
||||
Metadata::Entry f2 = meta_->markLocked(bufferType1, &frames[2]);
|
||||
|
||||
Metadata::Entry r0 = meta_->markLocked(bufferType1, &rawbuf[0]);
|
||||
Metadata::Entry r1 = meta_->markLocked(bufferType1, &rawbuf[1]);
|
||||
|
||||
CHECK (LOCKED == f0.state());
|
||||
CHECK (LOCKED == f1.state());
|
||||
CHECK (LOCKED == f2.state());
|
||||
CHECK (LOCKED == r0.state());
|
||||
CHECK (LOCKED == r1.state());
|
||||
|
||||
// for the TestFrame buffers, additionally we'd have to create/attach an object
|
||||
attachTestFrame.createAttached (frames+0); ////////////////////////////////////////TODO: shouldn't this happen automatically??
|
||||
attachTestFrame.createAttached (frames+1);
|
||||
attachTestFrame.createAttached (frames+2);
|
||||
|
||||
CHECK (f0.access() == frames+0);
|
||||
CHECK (f1.access() == frames+1);
|
||||
CHECK (f2.access() == frames+2);
|
||||
CHECK (r0.access() == rawbuf+0);
|
||||
CHECK (r1.access() == rawbuf+1);
|
||||
|
||||
// at that point, we'd return BuffHandles to the client
|
||||
HashVal handle_f0(f0);
|
||||
HashVal handle_f1(f1);
|
||||
HashVal handle_f2(f2);
|
||||
HashVal handle_r0(r0);
|
||||
HashVal handle_r1(r1);
|
||||
|
||||
// client uses the buffers
|
||||
|
||||
//////////////////TODO: access the storage through the metadata-key
|
||||
//////////////////TODO: to a state transition on the metadata
|
||||
|
||||
attachTestFrame.destroyAttached (frames+0); ////////////////////////////////////////TODO: shouldn't this happen automatically??
|
||||
attachTestFrame.destroyAttached (frames+1);
|
||||
attachTestFrame.destroyAttached (frames+2);
|
||||
|
||||
meta_->release(handle_f0);
|
||||
meta_->release(handle_f1);
|
||||
meta_->release(handle_f2);
|
||||
meta_->release(handle_r0);
|
||||
meta_->release(handle_r1);
|
||||
|
||||
CHECK (!meta_->isLocked(handle_f0));
|
||||
CHECK (!meta_->isLocked(handle_f1));
|
||||
CHECK (!meta_->isLocked(handle_f2));
|
||||
CHECK (!meta_->isLocked(handle_r0));
|
||||
CHECK (!meta_->isLocked(handle_r1));
|
||||
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #834
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #834
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ namespace test {
|
|||
// will be preconfigured, depending on the usage context
|
||||
BufferProvider& provider = DiagnosticBufferProvider::build();
|
||||
|
||||
BufferDescriptor desc1 = provider.getDescriptor<TestFrame>();
|
||||
BufferDescriptor desc1 = provider.getDescriptor<TestFrame>(); // note: implies also sizeof(TestFrame)
|
||||
BufferDescriptor desc2 = provider.getDescriptorFor(TEST_SIZE);
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #829
|
||||
CHECK (desc1.verifyValidity());
|
||||
|
|
|
|||
|
|
@ -77,13 +77,13 @@ namespace test {
|
|||
|
||||
|
||||
|
||||
TestFrame
|
||||
inline TestFrame
|
||||
testData (uint seqNr)
|
||||
{
|
||||
UNIMPLEMENTED ("build, memorise and expose test data frames on demand");
|
||||
}
|
||||
|
||||
TestFrame
|
||||
inline TestFrame
|
||||
testData (uint chanNr, uint seqNr)
|
||||
{
|
||||
UNIMPLEMENTED ("build, memorise and expose test data frames on demand (multi-channel)");
|
||||
|
|
|
|||
Loading…
Reference in a new issue