Block-Flow: introduce backlink into AllocationHandle
further implementation makes clear that the AllocationHandle, which is the primary usage front-end, has to rely both on services of the underlying ExtentFamily allocator, as well as on the BlockFlow itself for managing the Epoch spacing.
This commit is contained in:
parent
e4b74f3ae1
commit
6d75a82932
3 changed files with 52 additions and 28 deletions
|
|
@ -247,14 +247,18 @@ namespace gear {
|
|||
* maintained in fixed-sized _extents_ and thus allocations may
|
||||
* _overflow_ — leading to allocation of further extents. However,
|
||||
* this extension is handled transparently by the embedded iterator.
|
||||
* Moreover, a back-connection to the BlockFlow instance is maintained,
|
||||
* enabling the latter to manage the Epoch spacing dynamically.
|
||||
*/
|
||||
class AllocatorHandle
|
||||
{
|
||||
EpochIter epoch_;
|
||||
BlockFlow* flow_;
|
||||
|
||||
public:
|
||||
AllocatorHandle(Allocator::iterator slot)
|
||||
AllocatorHandle(Allocator::iterator slot, BlockFlow* parent)
|
||||
: epoch_{slot}
|
||||
, flow_{parent}
|
||||
{ }
|
||||
|
||||
/*************************************************//**
|
||||
|
|
@ -280,7 +284,12 @@ namespace gear {
|
|||
// Epoch overflow
|
||||
// use following Epoch; possibly allocate
|
||||
if (not epoch_)
|
||||
{
|
||||
auto lastDeadline = flow_->lastEpoch().deadline();
|
||||
epoch_.expandAlloc();
|
||||
ENSURE (epoch_);
|
||||
Epoch::setup (epoch_, lastDeadline + flow_->getEpochStep());
|
||||
}
|
||||
else
|
||||
++epoch_;
|
||||
return epoch_->gate().claimNextSlot();
|
||||
|
|
@ -297,13 +306,13 @@ namespace gear {
|
|||
{//just create new Epoch one epochStep ahead
|
||||
alloc_.openNew();
|
||||
Epoch::setup (alloc_.begin(), deadline + Time{epochStep_});
|
||||
return AllocatorHandle{alloc_.begin()};
|
||||
return AllocatorHandle{alloc_.begin(), this};
|
||||
}
|
||||
else
|
||||
{//find out how the given time relates to existing Epochs
|
||||
if (firstEpoch().deadline() >= deadline)
|
||||
// way into the past ... put it in the first available Epoch
|
||||
return AllocatorHandle{alloc_.begin()};
|
||||
return AllocatorHandle{alloc_.begin(), this};
|
||||
else
|
||||
if (lastEpoch().deadline() < deadline)
|
||||
{ // a deadline beyond the established Epochs...
|
||||
|
|
@ -324,7 +333,7 @@ namespace gear {
|
|||
if (deadline <= lastDeadline)
|
||||
{
|
||||
ENSURE (requiredNew == 1);
|
||||
return AllocatorHandle{nextEpoch};
|
||||
return AllocatorHandle{nextEpoch, this};
|
||||
} // break out and return handle to allocate into the matching Epoch
|
||||
++nextEpoch;
|
||||
}
|
||||
|
|
@ -333,7 +342,7 @@ namespace gear {
|
|||
else
|
||||
for (EpochIter epochIt{alloc_.begin()}; epochIt; ++epochIt)
|
||||
if (epochIt->deadline() >= deadline)
|
||||
return AllocatorHandle{epochIt};
|
||||
return AllocatorHandle{epochIt, this};
|
||||
|
||||
NOTREACHED ("Inconsistency in BlockFlow Epoch deadline organisation");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,8 +157,8 @@ namespace test {
|
|||
// the storage there is not yet used, but will be overwritten by the ctor call
|
||||
epoch[extent.size()-1].data_.timing.instant = Time{5,5};
|
||||
|
||||
// allocate a new Activity into the next free slot
|
||||
BlockFlow::AllocatorHandle allocHandle{alloc.begin()};
|
||||
// allocate a new Activity into the next free slot (using a faked AllocatorHandle)
|
||||
BlockFlow::AllocatorHandle allocHandle{alloc.begin(), nullptr};
|
||||
Activity& timeStart = allocHandle.create (Activity::TIMESTART);
|
||||
CHECK (isSameObject (timeStart, epoch[extent.size()-1]));
|
||||
|
||||
|
|
@ -177,17 +177,13 @@ namespace test {
|
|||
|
||||
// so let's eat this space up...
|
||||
for (uint i=extent.size()-2; i>1; --i)
|
||||
allocHandle.create();
|
||||
gate.claimNextSlot();
|
||||
|
||||
// one final slot is left (beyond of the EpochGate itself)
|
||||
CHECK (isSameObject (*gate.next, epoch[1]));
|
||||
CHECK (gate.hasFreeSlot());
|
||||
|
||||
allocHandle.create (size_t(111), size_t(222));
|
||||
CHECK (epoch[1].verb_ == Activity::FEED);
|
||||
CHECK (epoch[1].data_.feed.one = 111);
|
||||
CHECK (epoch[1].data_.feed.two = 222);
|
||||
|
||||
|
||||
gate.claimNextSlot();
|
||||
// aaand the boat is full...
|
||||
CHECK (not gate.hasFreeSlot());
|
||||
CHECK (isSameObject (*gate.next, epoch[0]));
|
||||
|
|
|
|||
|
|
@ -79949,6 +79949,21 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node COLOR="#338800" CREATED="1689265754039" ID="ID_199514628" MODIFIED="1689265769886" TEXT="Epoch::setup (rawStorageIter) extrahiert">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1689522759753" ID="ID_1883954151" MODIFIED="1689523106024" TEXT="brauche doch einen back-Link auf den BlockFlow selber">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
<p>
|
||||
Das ist eigentlich auch logisch-architektonisch sauber so: man bezieht sich sowohl auf den Allokator, als auch auf das Epochen-Management.
|
||||
</p><br/>
|
||||
<p>
|
||||
Durch einen Kniff ließe sich dieser Doppelbezug jedoch reduzieren, aber nur auf einen Bezug auf den BlockFlow (der dann kaskadierend auf die ExtentFamily rekurieren müßte). Dazu wäre es notwendig, in BlockFlow einen komplett eigenständigen Iterator zu implementieren; zudem müßte man darauf hoffen (⟹ überprüfen), daß der Optimiser diese kaskadierenden Aufrufe <b>für die reinie Iteration</b> komplett auflösen kann — andernfalls hätten wir einen Performance-Nachteil beim wichtigen/häufigen durchsuchen der Epochen nach dem passenden Slot. <i><font color="#731fc7">Daher nehme ich von dieser Lösung Abstand, und bleibe bei den klaren Bezügen.</font></i>
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<linktarget COLOR="#46c5b0" DESTINATION="ID_1883954151" ENDARROW="Default" ENDINCLINATION="313;0;" ID="Arrow_ID_335662186" SOURCE="ID_614501813" STARTARROW="None" STARTINCLINATION="293;-12;"/>
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1689436181499" FOLDED="true" ID="ID_32560484" MODIFIED="1689439546663" TEXT="IterExplorer entgleist">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
|
|
@ -79978,34 +79993,38 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689469187413" ID="ID_855611178" MODIFIED="1689469226130" TEXT="Weiterschalten beim Epoch-Overflow">
|
||||
<node COLOR="#338800" CREATED="1689469187413" ID="ID_855611178" MODIFIED="1689523118559" TEXT="Weiterschalten beim Epoch-Overflow">
|
||||
<arrowlink COLOR="#9d344c" DESTINATION="ID_586190414" ENDARROW="Default" ENDINCLINATION="-456;-39;" ID="Arrow_ID_1282441869" STARTARROW="None" STARTINCLINATION="-78;65;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689469246381" ID="ID_797279135" MODIFIED="1689469315636" TEXT="zwei verschiedene Aktionen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#435e98" CREATED="1689469246381" ID="ID_797279135" MODIFIED="1689522750277" STYLE="fork" TEXT="zwei verschiedene Aktionen">
|
||||
<font NAME="SansSerif" SIZE="12"/>
|
||||
<icon BUILTIN="idea"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689469261730" ID="ID_1257907954" MODIFIED="1689469311373" TEXT="nächsten vorhandenen Slot prüfen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1689469261730" ID="ID_1257907954" MODIFIED="1689522748787" TEXT="nächsten vorhandenen Slot prüfen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689469270049" ID="ID_1411978756" MODIFIED="1689469310557" TEXT="ggfs neuen Slot aufmachen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689469276848" ID="ID_521953438" MODIFIED="1689469309045" TEXT="Allokation auf ExtentFamily anstoßen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1689469270049" ID="ID_1411978756" MODIFIED="1689522748787" TEXT="ggfs neuen Slot aufmachen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1689469276848" ID="ID_521953438" MODIFIED="1689522748787" TEXT="Allokation auf ExtentFamily anstoßen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689469291822" ID="ID_1957125180" MODIFIED="1689469309045" TEXT="neuen Slot einrichten">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1689469291822" ID="ID_1957125180" MODIFIED="1689522748787" TEXT="neuen Slot einrichten">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689469296726" ID="ID_767704093" MODIFIED="1689469309046" TEXT="Overflow-Signal auslösen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1689469322050" ID="ID_960239976" MODIFIED="1689469348467" TEXT="Design-Problem: Zugriff auf Services">
|
||||
<node COLOR="#435e98" CREATED="1689469322050" ID="ID_960239976" MODIFIED="1689523094732" TEXT="Design-Problem: Zugriff auf Services">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
<node CREATED="1689469350142" ID="ID_1553565651" MODIFIED="1689469386822" TEXT="es passiert vom AllocationHandle aus">
|
||||
<icon BUILTIN="info"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689469360925" ID="ID_966350916" MODIFIED="1689469381514" TEXT="das kommt nicht direkt an den BlockFlow heran">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#435e98" CREATED="1689469360925" ID="ID_966350916" MODIFIED="1689523069078" TEXT="das kommt nicht direkt an den BlockFlow heran">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1689523070233" ID="ID_614501813" MODIFIED="1689523113487" TEXT="⟹ Konsequenz: brauche einen back-Link auf den BlockFlow">
|
||||
<arrowlink COLOR="#46c5b0" DESTINATION="ID_1883954151" ENDARROW="Default" ENDINCLINATION="313;0;" ID="Arrow_ID_335662186" STARTARROW="None" STARTINCLINATION="293;-12;"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue