|
MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
|
Token-based multimodal task scheduling system for unified coroutine processing. More...
#include <Scheduler.hpp>
Collaboration diagram for MayaFlux::Vruta::TaskScheduler:Public Member Functions | |
| TaskScheduler (uint32_t default_sample_rate=48000, uint32_t default_frame_rate=60) | |
| Constructs a TaskScheduler with the specified sample rate. | |
| void | 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. | |
| std::shared_ptr< Routine > | get_task (const std::string &name) const |
| Get a named task. | |
| bool | cancel_task (std::shared_ptr< Routine > task) |
| Cancels and removes a task from the scheduler. | |
| bool | cancel_task (const std::string &name) |
| Cancel a task by name. | |
| bool | restart_task (const std::string &name) |
| Restart a named task. | |
| std::vector< std::shared_ptr< Routine > > | get_tasks_for_token (ProcessingToken token) const |
| Get all tasks for a specific processing domain. | |
| void | process_token (ProcessingToken token, uint64_t processing_units=1) |
| Process all tasks for a specific processing domain. | |
| void | process_all_tokens () |
| Process all active domains. | |
| void | register_token_processor (ProcessingToken token, token_processing_func_t processor) |
| Register a custom processor for a specific token domain. | |
| uint64_t | seconds_to_units (double seconds, ProcessingToken token=ProcessingToken::SAMPLE_ACCURATE) const |
| Convert seconds to processing units for a specific domain. | |
| uint64_t | current_units (ProcessingToken token=ProcessingToken::SAMPLE_ACCURATE) const |
| Get current processing units for a domain. | |
| unsigned int | get_rate (ProcessingToken token=ProcessingToken::SAMPLE_ACCURATE) const |
| Get processing rate for a domain. | |
| uint64_t | seconds_to_samples (double seconds) const |
| Converts a time in seconds to a number of samples. | |
| const SampleClock & | get_sample_clock () const |
| Get the audio domain's SampleClock (legacy interface) | |
| const SampleClock & | get_clock () const |
| Gets the primary clock (audio domain for legacy compatibility) | |
| const IClock & | get_clock (ProcessingToken token=ProcessingToken::SAMPLE_ACCURATE) const |
| Get the clock for a specific processing domain. | |
| template<typename ClockType > | |
| const ClockType & | get_typed_clock (ProcessingToken token=ProcessingToken::SAMPLE_ACCURATE) const |
| Get a typed clock for a specific processing domain. | |
| template<typename... Args> | |
| bool | update_task_params (const std::string &name, Args &&... args) |
| Update parameters of a named task. | |
| template<typename T > | |
| T * | get_task_state (const std::string &name, const std::string &state_key) const |
| Get task state value by name and key. | |
| template<typename T > | |
| std::function< T()> | create_value_accessor (const std::string &name, const std::string &state_key) const |
| Create value accessor function for named task. | |
| uint64_t | get_next_task_id () const |
| Generates a unique task ID for new tasks. | |
| bool | has_active_tasks (ProcessingToken token) const |
| Check if a processing domain has any active tasks. | |
| std::vector< std::string > | get_task_names () const |
| Get all task names for debugging/inspection. | |
| void | pause_all_tasks () |
| Pause all active tasks. | |
| void | resume_all_tasks () |
| Resume all previously paused tasks. | |
| void | terminate_all_tasks () |
| Terminate and clear all tasks. | |
| uint32_t | get_cleanup_threshold () const |
| Get the task cleanup threshold. | |
| void | set_cleanup_threshold (uint32_t threshold) |
| Set the task cleanup threshold. | |
| uint64_t | get_current_buffer_cycle () const |
| Get current buffer cycle for task scheduling Updated by AudioSubsystem at each buffer boundary. | |
| void | tick_buffer_cycle () |
| Increment buffer cycle counter Called by AudioSubsystem at start of each buffer processing. | |
| void | process_buffer_cycle_tasks () |
Private Member Functions | |
| std::string | auto_generate_name (std::shared_ptr< Routine > routine) const |
| Generate automatic name for a routine based on its type. | |
| std::vector< TaskEntry >::iterator | find_task_by_name (const std::string &name) |
| Find task entry by name. | |
| std::vector< TaskEntry >::const_iterator | find_task_by_name (const std::string &name) const |
| Find task entry by name (const version) | |
| std::vector< TaskEntry >::iterator | find_task_by_routine (std::shared_ptr< Routine > routine) |
| Find task entry by routine pointer. | |
| void | ensure_domain (ProcessingToken token, unsigned int rate=0) |
| Initialize a processing domain if it doesn't exist. | |
| unsigned int | get_default_rate (ProcessingToken token) const |
| Get the default rate for a processing token. | |
| void | process_default (ProcessingToken token, uint64_t processing_units) |
| Process tasks in a specific domain with default algorithm. | |
| void | cleanup_completed_tasks () |
| Clean up completed tasks in a domain. | |
| bool | initialize_routine_state (std::shared_ptr< Routine > routine, ProcessingToken token) |
| Initialize a routine's state for a specific domain. | |
Private Attributes | |
| std::unordered_map< ProcessingToken, std::unique_ptr< IClock > > | m_token_clocks |
| Clock instances for each processing domain. | |
| std::unordered_map< ProcessingToken, token_processing_func_t > | m_token_processors |
| Custom processors for specific domains. | |
| std::unordered_map< ProcessingToken, unsigned int > | m_token_rates |
| Default processing rates for each domain. | |
| std::atomic< uint64_t > | m_next_task_id { 1 } |
| Task ID counter for unique identification. | |
| std::vector< TaskEntry > | m_tasks |
| SampleClock | m_clock |
| The master sample clock for the processing engine. | |
| uint32_t | m_cleanup_threshold |
| Threshold for task cleanup. | |
| uint64_t | m_current_buffer_cycle {} |
Token-based multimodal task scheduling system for unified coroutine processing.
TaskScheduler serves as the central orchestrator for coroutine scheduling in the MayaFlux engine, implementing a token-based architecture that enables seamless integration of different processing domains while maintaining proven audio scheduling patterns. This design enables true digital-first, data-driven multimedia task scheduling where audio, visual, and custom coroutines can coexist in a unified scheduling system.
Core Architecture:
The scheduler creates appropriate clocks and task lists based on processing tokens, ensuring optimal performance for each domain while enabling cross-domain synchronization.
Definition at line 51 of file Scheduler.hpp.