OutputSlot: setup a dedicated proxy-provider structure
Now the »pathfinder« prototype, the `BufferProxyProvider` turns out as a good starting point; just can simplify a lot and omit the outer capsule.
This commit is contained in:
parent
2ee6bb3b04
commit
0438571b73
3 changed files with 63 additions and 39 deletions
|
|
@ -66,15 +66,15 @@ namespace out {
|
|||
* - callback functors for the lifecycle stages related to the client's access
|
||||
* @todo 3/2026 this is prototyping code and was retained for demonstration purposes.
|
||||
*/
|
||||
template<class CONF>
|
||||
template<class HUB>
|
||||
class OutputBufferProxy
|
||||
: util::NonCopyable
|
||||
: public BufferProviderSetup
|
||||
{
|
||||
|
||||
class ProxyBufferStore
|
||||
class OutputBufferStore
|
||||
: public BufferProviderSetup::Store
|
||||
, private CONF
|
||||
{
|
||||
HUB& output_;
|
||||
|
||||
Buff*
|
||||
asBuffer (LocalTag targetMarker)
|
||||
|
|
@ -86,8 +86,7 @@ namespace out {
|
|||
uint
|
||||
prepareBuffers (HashVal,uint,size_t) override
|
||||
{
|
||||
WARN (engine, "Announce invoked on a Proxy Buffer Provider; "
|
||||
"Implies misuse as generic BufferProvider");
|
||||
NOTREACHED ("This is not a general purpose BufferProvider");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -95,67 +94,57 @@ namespace out {
|
|||
provideBuffer (HashVal,size_t siz,LocalTag targetMarker) override
|
||||
{
|
||||
BuffAlloc storageSlot{asBuffer(targetMarker), siz, targetMarker};
|
||||
CONF::on_lock (storageSlot);
|
||||
TODO ("delegate buffer lock");
|
||||
return storageSlot;
|
||||
}
|
||||
|
||||
void
|
||||
mark_emitted (HashVal, BuffAlloc storageSlot) override
|
||||
{
|
||||
CONF::on_emit (storageSlot);
|
||||
TODO ("delegate buffer emit");
|
||||
}
|
||||
|
||||
void
|
||||
detachBuffer (HashVal, BuffAlloc storageSlot) override
|
||||
{
|
||||
CONF::on_release (storageSlot);
|
||||
TODO ("delegate buffer release");
|
||||
}
|
||||
|
||||
public:
|
||||
ProxyBufferStore (CONF policy)
|
||||
: CONF{move(policy)}
|
||||
OutputBufferStore(HUB& outputHub)
|
||||
: output_{outputHub}
|
||||
{ }
|
||||
};
|
||||
|
||||
struct Setup
|
||||
: CONF
|
||||
{
|
||||
auto buildStage() { return std::make_unique<vault::mem::SimpleBufferStateRegistry>("OutputBufferProxy"); }
|
||||
auto buildStore() { return std::make_unique<ProxyBufferStore> (move(*this)); }
|
||||
}; // Note: possible since Setup does not use CONF
|
||||
|
||||
class PassThroughBufferProvider
|
||||
: public BufferProviderSetup
|
||||
{
|
||||
HUB& outputHub_;
|
||||
|
||||
public:
|
||||
PassThroughBufferProvider (Setup setup)
|
||||
: BufferProviderSetup{setup}
|
||||
{ }
|
||||
|
||||
BuffDescr
|
||||
registerBuffer (void* buff, size_t siz)
|
||||
{
|
||||
REQUIRE (siz);
|
||||
REQUIRE (buff);
|
||||
auto& typeKey = bufferStage_->defineBufferType (siz, TypeHandler::RAW, LocalTag(buff));
|
||||
return buildDescriptor (typeKey);
|
||||
}
|
||||
auto buildStage() { return std::make_unique<vault::mem::SimpleBufferStateRegistry>("OutputBufferProxy"); }
|
||||
auto buildStore() { return std::make_unique<OutputBufferStore> (outputHub_); }
|
||||
};
|
||||
|
||||
PassThroughBufferProvider proxyProvider_;
|
||||
|
||||
BuffDescr
|
||||
registerBuffer (void* buff, size_t siz)
|
||||
{
|
||||
REQUIRE (siz);
|
||||
REQUIRE (buff);
|
||||
auto& typeKey = bufferStage_->defineBufferType (siz, TypeHandler::RAW, LocalTag(buff));
|
||||
return buildDescriptor (typeKey);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
OutputBufferProxy(CONF policy)
|
||||
: proxyProvider_{Setup{move(policy)}}
|
||||
OutputBufferProxy(HUB& outputHub)
|
||||
: BufferProviderSetup{Setup{outputHub}}
|
||||
{ }
|
||||
|
||||
|
||||
template<typename TAR>
|
||||
BuffDescr
|
||||
getDescriptorFor (TAR& dataBlock)
|
||||
{
|
||||
return proxyProvider_.registerBuffer(&dataBlock, sizeof(TAR));
|
||||
return registerBuffer(&dataBlock, sizeof(TAR));
|
||||
}
|
||||
|
||||
template<typename TAR>
|
||||
|
|
|
|||
|
|
@ -130,6 +130,9 @@ namespace out {
|
|||
|
||||
Connections connections_;
|
||||
|
||||
OutputBufferProxy<AllocState> proxyBufferProvider_;
|
||||
|
||||
|
||||
|
||||
/* == Allocation Interface == */
|
||||
|
||||
|
|
@ -173,6 +176,7 @@ namespace out {
|
|||
template<class CTOR>
|
||||
AllocState(uint numChannels, CTOR&& populator)
|
||||
: connections_(numChannels, std::forward<CTOR>(populator))
|
||||
, proxyBufferProvider_{*this}
|
||||
{ }
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -138099,7 +138099,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
<node CREATED="1773704486520" ID="ID_1324797839" MODIFIED="1773704500571" TEXT="sie haben nur den Buffer-Ptr, nicht die dazugehörige Connection"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1773797100647" ID="ID_425446315" MODIFIED="1773797118509" TEXT="Überlegung: wie könnt man das Problem überhaupt »knacken«">
|
||||
<node COLOR="#435e98" CREATED="1773797100647" ID="ID_425446315" MODIFIED="1773888697408" TEXT="Überlegung: wie könnt man das Problem überhaupt »knacken«">
|
||||
<icon BUILTIN="help"/>
|
||||
<node CREATED="1773797120055" ID="ID_1455782398" MODIFIED="1773797126986" TEXT="mit Gewalt?">
|
||||
<node CREATED="1773797138856" ID="ID_1366418982" MODIFIED="1773797219006" TEXT="jede DataSink bekommt auch einen Basis-Descriptor(⟼backlink)"/>
|
||||
<node CREATED="1773797234722" ID="ID_928593244" MODIFIED="1773797318457" TEXT="jedesmal wenn eine Connection einen Buffer ausgibt, meldet sie das beim AllocState"/>
|
||||
|
|
@ -138172,7 +138173,37 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
|
|||
<node CREATED="1773875219107" ID="ID_1212468658" MODIFIED="1773875229312" TEXT="ich kann den ja für andere Zwecke mal bestehen lassen"/>
|
||||
<node CREATED="1773875230170" ID="ID_1330974689" MODIFIED="1773875244308" TEXT="er war wichtig, um den Mismatch in den APIs zu erkennen und dann zu beheben"/>
|
||||
<node CREATED="1773875245243" ID="ID_1639451717" MODIFIED="1773875299381" TEXT="die dort erstmals verwendeten generierten Datentypen sind anderweitig nützlich"/>
|
||||
<node CREATED="1773875306072" ID="ID_1024103205" MODIFIED="1773875342503" TEXT="was wir brauchen: eine direkt an AllocState delegierende BufferStore-Implementierung"/>
|
||||
<node CREATED="1773875306072" ID="ID_1024103205" MODIFIED="1773888756205" TEXT="was wir brauchen: eine direkt an AllocState delegierende BufferStore-Implementierung">
|
||||
<arrowlink COLOR="#617685" DESTINATION="ID_1250247595" ENDARROW="Default" ENDINCLINATION="642;34;" ID="Arrow_ID_1889600265" STARTARROW="None" STARTINCLINATION="-211;7;"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1773888286270" ID="ID_1279395018" MODIFIED="1773888766729" TEXT="Fazit">
|
||||
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
|
||||
<icon BUILTIN="forward"/>
|
||||
<node CREATED="1773888290871" ID="ID_1640123820" MODIFIED="1773888299240" TEXT="DataSink wird unique"/>
|
||||
<node CREATED="1773888299988" ID="ID_1909698021" MODIFIED="1773888311487" TEXT="DataSink verweist auf den PImpl (AllocState)">
|
||||
<node CREATED="1773888330075" ID="ID_1924701415" MODIFIED="1773888346410" TEXT="hier wird ein neues Interface benötigt"/>
|
||||
<node CREATED="1773888364124" ID="ID_1625145338" MODIFIED="1773888376862" TEXT="oder eine vergleichbare implementation-level-Indirektion"/>
|
||||
<node CREATED="1773888380609" ID="ID_1459481812" MODIFIED="1773888395051" TEXT="(Grund: AllocState ist getemplated auf die tatsächliche Connection)"/>
|
||||
</node>
|
||||
<node CREATED="1773888404158" ID="ID_1250247595" MODIFIED="1773888756205" TEXT="eine neue Hilfskomponente bauen: OutputBufferProxy">
|
||||
<linktarget COLOR="#617685" DESTINATION="ID_1250247595" ENDARROW="Default" ENDINCLINATION="642;34;" ID="Arrow_ID_1889600265" SOURCE="ID_1024103205" STARTARROW="None" STARTINCLINATION="-211;7;"/>
|
||||
</node>
|
||||
<node CREATED="1773888426603" ID="ID_888618711" MODIFIED="1773888441501" TEXT="diese enhält einen »delegating-BufferStore«"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1773888677730" ID="ID_370790574" MODIFIED="1773888690633" TEXT="dieses neue Verschaltungs-Konzept implementieren">
|
||||
<icon BUILTIN="flag-pink"/>
|
||||
<node COLOR="#338800" CREATED="1773888784963" ID="ID_1753071442" MODIFIED="1773888798826" TEXT="Struktur eines Proxy-BufferProvider anlegen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1773888800028" ID="ID_756667017" MODIFIED="1773888814028" TEXT="geht ganz einfach: von BufferProxyAdapter ausgehen"/>
|
||||
<node CREATED="1773888814799" ID="ID_1048707778" MODIFIED="1773888823194" TEXT="kann hier aber die ganze äußere Hülle weglassen"/>
|
||||
<node CREATED="1773888824142" ID="ID_16971375" MODIFIED="1773888832921" TEXT="auch die Policy-Konfiguration fällt weg"/>
|
||||
<node CREATED="1773888833797" ID="ID_473209009" MODIFIED="1773888851679" TEXT="jedoch der Setup-Mechanismus ist auch hier hilfreich">
|
||||
<node CREATED="1773888855315" ID="ID_1311998927" MODIFIED="1773888861475" TEXT="verwende einen Setup-Hiflstyp"/>
|
||||
<node CREATED="1773888862176" ID="ID_25602564" MODIFIED="1773888872388" TEXT="dieser wird nur transient während dem Konstruktor erzeugt"/>
|
||||
<node CREATED="1773888873544" ID="ID_1930210997" MODIFIED="1773888889891" TEXT="Vorteil: ich kann die back-Reference nach innen in den BufferStore schieben"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue