MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write() [11/12]

void MayaFlux::Portal::Forma::Bridge::write ( uint32_t  id,
std::shared_ptr< Buffers::DataWriteProcessor target 
)

Route element value to a DataWriteProcessor each frame.

Parameters
idElement id.
targetDataWriteProcessor to call set_data() on.

Definition at line 198 of file Bridge.cpp.

199{
200 auto it = m_records.find(id);
201 if (it == m_records.end()) {
203 "Bridge::write: unknown element id {}", id);
204 return;
205 }
206
207 auto name = make_task_name(id, "geometry");
208 it->second.outbound_tasks.push_back(name);
209
210 auto bulk = it->second.bulk_reader;
211 auto reader = it->second.reader;
212
213 if (bulk) {
214 auto routine = [](Vruta::TaskScheduler&,
215 std::function<std::vector<float>()> b,
216 std::shared_ptr<Buffers::DataWriteProcessor> proc)
217 -> Vruta::GraphicsRoutine {
218 auto& p = co_await Kriya::GetGraphicsPromise {};
219 while (!p.should_terminate) {
220 proc->set_data(Kakshya::DataVariant { b() });
221 co_await Kriya::FrameDelay { .frames_to_wait = 1 };
222 }
223 };
225 std::make_shared<Vruta::GraphicsRoutine>(
226 routine(m_scheduler, std::move(bulk), std::move(target))),
227 name, false);
228 } else {
229 auto routine = [](Vruta::TaskScheduler&,
230 std::function<float()> r,
231 std::shared_ptr<Buffers::DataWriteProcessor> proc)
232 -> Vruta::GraphicsRoutine {
233 auto& p = co_await Kriya::GetGraphicsPromise {};
234 while (!p.should_terminate) {
235 proc->set_data(std::vector<Kakshya::DataVariant> { Kakshya::DataVariant { std::vector<float> { r() } } });
236 co_await Kriya::FrameDelay { .frames_to_wait = 1 };
237 }
238 };
240 std::make_shared<Vruta::GraphicsRoutine>(
241 routine(m_scheduler, std::move(reader), std::move(target))),
242 name, false);
243 }
244}
#define MF_ERROR(comp, ctx,...)
size_t b
Vruta::TaskScheduler & m_scheduler
Definition Bridge.hpp:522
std::string make_task_name(uint32_t id, const char *suffix) const
Definition Bridge.cpp:346
std::unordered_map< uint32_t, ElementRecord > m_records
Definition Bridge.hpp:527
void add_task(const std::shared_ptr< Routine > &routine, const std::string &name="", bool initialize=false)
Add a routine to the scheduler based on its processing token.
Definition Scheduler.cpp:23
@ Init
Engine/subsystem initialization.
@ Portal
High-level user-facing API layer.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
Definition NDData.hpp:76
GetPromiseBase< Vruta::graphics_promise > GetGraphicsPromise
Graphics domain promise accessor.

References MayaFlux::Vruta::TaskScheduler::add_task(), b, MayaFlux::Kriya::FrameDelay::frames_to_wait, MayaFlux::Journal::Init, m_records, m_scheduler, make_task_name(), MF_ERROR, and MayaFlux::Journal::Portal.

+ Here is the call graph for this function: