using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Threading; using Kyoo.Abstractions.Models.Attributes; using Kyoo.Abstractions.Models.Exceptions; namespace Kyoo.Abstractions.Controllers { /// /// A service to handle long running tasks. /// /// The concurrent number of running tasks is implementation dependent. public interface ITaskManager { /// /// Start a new task (or queue it). /// /// /// The slug of the task to run. /// /// /// A progress reporter to know the percentage of completion of the task. /// /// /// A list of arguments to pass to the task. An automatic conversion will be made if arguments to not fit. /// /// /// A custom cancellation token for the task. /// /// /// If the number of arguments is invalid, if an argument can't be converted or if the task finds the argument /// invalid. /// /// /// The task could not be found. /// void StartTask(string taskSlug, [NotNull] IProgress progress, Dictionary arguments = null, CancellationToken? cancellationToken = null); /// /// Start a new task (or queue it). /// /// /// A progress reporter to know the percentage of completion of the task. /// /// /// A list of arguments to pass to the task. An automatic conversion will be made if arguments to not fit. /// /// /// The type of the task to start. /// /// /// A custom cancellation token for the task. /// /// /// If the number of arguments is invalid, if an argument can't be converted or if the task finds the argument /// invalid. /// /// /// The task could not be found. /// void StartTask([NotNull] IProgress progress, Dictionary arguments = null, CancellationToken? cancellationToken = null) where T : ITask; /// /// Get all currently running tasks /// /// A list of currently running tasks. ICollection<(TaskMetadataAttribute, ITask)> GetRunningTasks(); /// /// Get all available tasks /// /// A list of every tasks that this instance know. ICollection GetAllTasks(); } }