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

◆ add_task()

void MayaFlux::Vruta::TaskScheduler::add_task ( std::shared_ptr< Routine routine,
const std::string &  name = "",
bool  initialize = false 
)

Add a routine to the scheduler based on its processing token.

Parameters
routineRoutine to add (SoundRoutine, GraphicsRoutine, or ComplexRoutine)
nameOptional name for the routine (for task management)
initializeWhether to initialize the routine's state immediately

The routine's processing token determines which domain it belongs to and which clock it synchronizes with. Automatically dispatches to the appropriate token-specific task list and clock synchronization.

Definition at line 17 of file Scheduler.cpp.

18{
19 if (!routine) {
20 std::cerr << "Failed to initiate routine\n;\t >> Exiting" << std::endl;
21 return;
22 }
23
24 std::string task_name = name.empty() ? auto_generate_name(routine) : name;
25 ProcessingToken token = routine->get_processing_token();
26
27 {
28 auto existing_it = find_task_by_name(task_name);
29 if (existing_it != m_tasks.end()) {
30 if (existing_it->routine && existing_it->routine->is_active()) {
31 existing_it->routine->set_should_terminate(true);
32 }
33 m_tasks.erase(existing_it);
34 }
35
36 m_tasks.emplace_back(routine, task_name);
37 }
38
39 if (initialize) {
42 } else {
44 }
45}
static MayaFlux::Nodes::ProcessingToken token
Definition Timers.cpp:8
std::vector< TaskEntry > m_tasks
bool initialize_routine_state(std::shared_ptr< Routine > routine, ProcessingToken token)
Initialize a routine's state for a specific domain.
std::vector< TaskEntry >::iterator find_task_by_name(const std::string &name)
Find task entry by name.
void ensure_domain(ProcessingToken token, unsigned int rate=0)
Initialize a processing domain if it doesn't exist.
std::string auto_generate_name(std::shared_ptr< Routine > routine) const
Generate automatic name for a routine based on its type.
void initialize()
Definition main.cpp:11

References auto_generate_name(), ensure_domain(), find_task_by_name(), initialize(), initialize_routine_state(), m_tasks, and token.

Referenced by MayaFlux::Kriya::BufferPipeline::dispatch_branch_async(), MayaFlux::Kriya::BufferPipeline::execute_buffer_rate(), MayaFlux::Kriya::BufferPipeline::execute_for_cycles(), MayaFlux::Kriya::BufferPipeline::execute_once(), MayaFlux::Kriya::BufferPipeline::execute_scheduled(), MayaFlux::Kriya::Timer::schedule(), and MayaFlux::Kriya::EventChain::start().

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