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

◆ spawn_sync()

void MayaFlux::Portal::Forma::Bridge::spawn_sync ( Layer &  layer,
uint32_t  id,
std::function< void()>  sync_fn 
)

Spawn a presentation sync task scoped to a Layer.

The task name is also stored in the outbound_tasks of the record for id, when one exists, so that unbind() cancels it. layer must be owned by a shared_ptr.

Parameters
layerLayer that owns the task.
idElement id used for task naming and diagnostics.
sync_fnFunction invoked once per graphics frame.

Definition at line 450 of file Bridge.cpp.

451{
452 auto name = make_task_name(id, "sync");
453 const ElementRef ref { layer.weak_from_this(), id };
454 m_layer_tasks[ref.first].push_back(name);
455 if (auto* rec = find_record(ref))
456 rec->outbound_tasks.push_back(name);
457
458 auto routine = [](Vruta::TaskScheduler&,
459 std::function<void()> fn) -> Vruta::GraphicsRoutine {
460 auto& p = co_await Kriya::GetGraphicsPromise {};
461 while (!p.should_terminate) {
462 fn();
463 co_await Kriya::FrameDelay { .frames_to_wait = 1 };
464 }
465 };
466
468 std::make_shared<Vruta::GraphicsRoutine>(
469 routine(m_scheduler, std::move(sync_fn))),
470 name, false);
471}
std::string name
Definition VKDevice.cpp:123
std::map< std::weak_ptr< Layer >, std::vector< std::string >, std::owner_less<> > m_layer_tasks
Definition Bridge.hpp:699
Vruta::TaskScheduler & m_scheduler
Definition Bridge.hpp:693
std::string make_task_name(uint32_t id, const char *suffix) const
Definition Bridge.cpp:416
ElementRecord * find_record(const ElementRef &ref)
Definition Bridge.cpp:406
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:94
GetPromiseBase< Vruta::graphics_promise > GetGraphicsPromise
Graphics domain promise accessor.
std::pair< std::weak_ptr< Layer >, uint32_t > ElementRef
Layer-scoped element identity.
Definition Bridge.hpp:34

References MayaFlux::Vruta::TaskScheduler::add_task(), find_record(), MayaFlux::Kriya::FrameDelay::frames_to_wait, m_layer_tasks, m_scheduler, make_task_name(), and name.

Referenced by MayaFlux::Portal::Forma::inspect(), MayaFlux::Portal::Forma::inspect(), MayaFlux::Portal::Forma::inspect(), MayaFlux::Portal::Forma::inspect(), MayaFlux::Portal::Forma::inspect_buffers(), MayaFlux::Portal::Forma::inspect_events(), MayaFlux::Portal::Forma::inspect_node_graph(), and MayaFlux::Portal::Forma::inspect_scheduler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: