OutputSlot: setup a DataSink wired to the proxy-BufferProvider

...this is the gordian λ

Note
 - embedding a copy of the shared-ptr in the closure
 - pre-configure a buffer descriptor (buffer type)
   * with the buffer size as retrieved from the connection
   * and pass the connection itself marked as LocalTag

Thus, on invocation of the DataSink (functor), it suffices
to invoke the lock() function on the BufferDescriptor,
using the new additional argument introduced with the
preceding commit
This commit is contained in:
Fischlurch 2026-03-22 17:36:38 +01:00
parent eeedb7a028
commit f29ec44fda
6 changed files with 70 additions and 32 deletions

View file

@ -135,6 +135,12 @@ namespace out {
/* === Connection API === */
size_t
getBufferSize() const override
{
UNIMPLEMENTED ("wtf buff?");
}
Buff*
claimBufferFor (FrameID frameNr) override
{

View file

@ -116,15 +116,6 @@ namespace out {
auto buildStore() { return std::make_unique<OutputBufferStore>(); }
};
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()
@ -132,20 +123,13 @@ namespace out {
{ }
template<typename TAR>
BuffDescr
getDescriptorFor (TAR& dataBlock)
getDescriptorFor (CON& connection)
{
return registerBuffer(&dataBlock, sizeof(TAR));
}
template<typename TAR>
BuffHandle
lockBuffer (TAR& dataBlock)
{
BuffDescr buffType = getDescriptorFor<TAR> (dataBlock);
ENSURE (buffType.isValid());
return buffType.lockBuffer();
LocalTag connectionID{&connection};
size_t buffSiz = connection.getBufferSize();
auto& typeKey = bufferStage_->defineBufferType (buffSiz, TypeHandler::RAW, connectionID);
return buildDescriptor (typeKey);
}
};

View file

@ -35,7 +35,7 @@
#include "vault/out/output-slot.hpp"
#include "vault/out/output-buffer-proxy.hpp"
#include "lib/scoped-collection.hpp"
#include "lib/iter-adapter-stl.hpp"
#include "lib/iter-explorer.hpp"
#include "lib/iter-source.hpp"
#include "lib/handle.hpp"
#include "lib/time/timevalue.hpp"
@ -43,6 +43,7 @@
//#include "steam/play/timings.hpp"
//#include "lib/sync.hpp"
#include "vault/mem/buffer-provider.hpp"
#include "lib/util.hpp"
//#include <string>
#include <functional>
@ -59,7 +60,7 @@ namespace out {
using vault::mem::BufferProvider;
using lib::time::TimeValue; /////////////////OOO Rly?
//using std::string;
using lib::iter_stl::eachElm;
using util::unConst;
//using std::placeholders::_1;
//using std::bind;
@ -95,6 +96,7 @@ namespace out {
public:
virtual ~Connection();
virtual size_t getBufferSize() const =0;
virtual Buff* claimBufferFor(FrameID) =0;
virtual bool isTimely (FrameID, TimeValue) =0;
virtual void transfer (Buff*) =0;
@ -151,7 +153,17 @@ namespace out {
OpenedSinks
connect (PAlloc& lifecycleManager) override
{
/////////////////OOO use an iterExplorer-Pipeline to create the functor closure here
return lib::explore (connections_)
.transform([&](CON& connection) -> DataSink
{ // setup the DataSink functor
return [bufferDescriptor = bufferProxy_.getDescriptorFor (connection)
,lifecycleManager ]
(FrameID frame) mutable -> BuffHandle
{
return bufferDescriptor.lockBuffer (frame);
};
})
.asIterSource();
}

View file

@ -32,7 +32,7 @@
** retrieving this OutputSlot. For example, a stereo sound output may expect only a single
** data feed, where data blocks for both channels are sent in interleaved format.
**
** Once the client retrieves some OutputSlot, it was _allocated_ for exclusive use for that client;
** Once the client retrieves some OutputSlot, it was _allocated_ for exclusive use for that client.
** At any time, there may be only a single client using a given output capability this way. It should
** be noted thus that output slots don't provide any kind of inherent mixing capability; any adaptation,
** mixing, overlaying and sharing needs to be done within the Render Node Network that produces the
@ -115,7 +115,13 @@ namespace out {
*/
class DataSink
: public std::function<BuffHandle(FrameID)>
{ };
{
public:
template<typename FUN>
DataSink (FUN&& fun)
: std::function<BuffHandle(FrameID)>{std::forward<FUN> (fun)}
{ }
};

View file

@ -80,6 +80,7 @@ namespace test {
class UnimplementedConnection
: public vault::out::OutputSlot::Connection
{
size_t getBufferSize() const override { UNIMPLEMENTED ("getBufferSize()"); }
Buff* claimBufferFor (FrameID) override;
bool isTimely (FrameID, TimeValue) override { return true; }
void transfer (Buff*) override { UNIMPLEMENTED ("transfer (BuffHandle const&)"); }

View file

@ -138663,7 +138663,35 @@ StM_bind(Builder&lt;R1&gt; b1, Extension&lt;R1,R2&gt; extension)
</node>
<node CREATED="1774124656373" ID="ID_1252354115" MODIFIED="1774127022008" TEXT="also binden in die Funktor-Closure">
<icon BUILTIN="forward"/>
<node CREATED="1774124694439" ID="ID_775305943" MODIFIED="1774124714000" TEXT="ein shared-ptr mit Alias auf die jeweilige Connection"/>
<node CREATED="1774124694439" ID="ID_775305943" MODIFIED="1774197102402">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
ein shared-ptr <strike>mit <font color="#673c22">Alias auf die jeweilige Connection</font></strike>
</p>
</body>
</html>
</richcontent>
<node COLOR="#5b280f" CREATED="1774196855086" ID="ID_535181506" MODIFIED="1774196868083" TEXT="brauche gar keinen Alias">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1774196869133" ID="ID_733223522" MODIFIED="1774196884004" TEXT="die Connection kann ich bereits in den Buffer-Descriptor einbetten">
<icon BUILTIN="idea"/>
</node>
<node CREATED="1774196885651" ID="ID_840999997" MODIFIED="1774197066154" TEXT="also brauche nur einen shared-ptr als lifecycle-Handle">
<icon BUILTIN="forward"/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1774196906696" ID="ID_136318391" MODIFIED="1774197060965" TEXT="wird im Body des Lambda gar nicht verwendet">
<icon BUILTIN="messagebox_warning"/>
</node>
<node CREATED="1774196919046" ID="ID_643798814" MODIFIED="1774196936088" TEXT="trotzdem explizit binden im &#x3bb;-capture"/>
<node CREATED="1774197007200" ID="ID_1031192090" LINK="https://stackoverflow.com/a/12718425/444796" MODIFIED="1774197049385" TEXT="Stackoverflow: C++ garantiert da&#xdf; das Binding erhalten bleibt">
<icon BUILTIN="info"/>
</node>
</node>
</node>
<node CREATED="1774124730203" ID="ID_257841074" MODIFIED="1774124780343" TEXT="ein vertig verdrahteter Buffer-Descriptor (&#x27f6; Connection)">
<node COLOR="#5b280f" CREATED="1774126323430" ID="ID_497118718" MODIFIED="1774126743220" TEXT="doch wieder Buffer-Descriptor-Refinement?">
<richcontent TYPE="NOTE"><html>
@ -138682,16 +138710,17 @@ StM_bind(Builder&lt;R1&gt; b1, Extension&lt;R1,R2&gt; extension)
</node>
</node>
</node>
<node CREATED="1774126316622" ID="ID_1460072236" MODIFIED="1774126322206" TEXT="Argumente">
<node CREATED="1774126316622" ID="ID_1460072236" MODIFIED="1774197144964" TEXT="Argumente">
<icon BUILTIN="list"/>
<node CREATED="1774126777267" ID="ID_1310012432" MODIFIED="1774126788414" TEXT="den shared-ptr als &#xbb;lifecycle-manager&#xab;"/>
<node CREATED="1774126796040" ID="ID_1259439489" MODIFIED="1774126831327" TEXT="die jeweils relevante Connection (&#x27f6; als Pointer/Referenz)"/>
<node CREATED="1774126856640" ID="ID_1792742469" MODIFIED="1774126864387" TEXT="von dieser Connection die Buffer-Size"/>
<node CREATED="1774126881885" ID="ID_899991315" MODIFIED="1774126887766" TEXT="der Proxy-BufferProvider"/>
<node CREATED="1774126881885" ID="ID_899991315" MODIFIED="1774197139349" TEXT="der Proxy-BufferProvider (&#x27f6; implizit im Buffer-Descriptor)"/>
</node>
</node>
<node BACKGROUND_COLOR="#fafe99" COLOR="#fa002a" CREATED="1774132649643" ID="ID_1759796259" MODIFIED="1774132670265" TEXT="Problem &#xfc;bersehen: die Frame-Nummer">
<node COLOR="#435e98" CREATED="1774132649643" ID="ID_1759796259" MODIFIED="1774190645402" TEXT="Problem &#xfc;bersehen: die Frame-Nummer">
<icon BUILTIN="broken-line"/>
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1774132731585" ID="ID_396286799" MODIFIED="1774136559514">
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1774132731585" ID="ID_396286799" MODIFIED="1774190638918">
<richcontent TYPE="NODE"><html>
<head/>
<body>
@ -138738,7 +138767,7 @@ StM_bind(Builder&lt;R1&gt; b1, Extension&lt;R1,R2&gt; extension)
</node>
<node CREATED="1774133338567" ID="ID_1915597180" MODIFIED="1774133354752" TEXT="v&#xf6;llig egal wie, in jedem Fall ist die Frame-Nummer eine zus&#xe4;tzliche Info"/>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1774133516471" ID="ID_1070291197" MODIFIED="1774136481626" TEXT="&#x27f9; bleibt nur, einen Kanal zu schaffen">
<node COLOR="#435e98" CREATED="1774133516471" ID="ID_1070291197" MODIFIED="1774190629188" TEXT="&#x27f9; bleibt nur, einen Kanal zu schaffen">
<icon BUILTIN="yes"/>
<node CREATED="1774133549299" ID="ID_437134456" MODIFIED="1774134318162" TEXT="L&#xf6;sung-1 : zus&#xe4;tzliches Argument durchf&#xe4;deln">
<icon BUILTIN="forward"/>