mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-29 12:14:49 +03:00
Cleanup tasks
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -41,21 +39,16 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
ScheduledTasks = Array.Empty<IScheduledTaskWorker>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of Scheduled Tasks.
|
||||
/// </summary>
|
||||
/// <value>The scheduled tasks.</value>
|
||||
public IScheduledTaskWorker[] ScheduledTasks { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<IScheduledTaskWorker> ScheduledTasks { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cancels if running and queue.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The task type.</typeparam>
|
||||
/// <param name="options">Task options.</param>
|
||||
/// <inheritdoc />
|
||||
public void CancelIfRunningAndQueue<T>(TaskOptions options)
|
||||
where T : IScheduledTask
|
||||
{
|
||||
@@ -65,16 +58,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
QueueScheduledTask<T>(options);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void CancelIfRunningAndQueue<T>()
|
||||
where T : IScheduledTask
|
||||
{
|
||||
CancelIfRunningAndQueue<T>(new TaskOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels if running.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The task type.</typeparam>
|
||||
/// <inheritdoc />
|
||||
public void CancelIfRunning<T>()
|
||||
where T : IScheduledTask
|
||||
{
|
||||
@@ -82,11 +73,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
((ScheduledTaskWorker)task).CancelIfRunning();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues the scheduled task.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The task type.</typeparam>
|
||||
/// <param name="options">Task options.</param>
|
||||
/// <inheritdoc />
|
||||
public void QueueScheduledTask<T>(TaskOptions options)
|
||||
where T : IScheduledTask
|
||||
{
|
||||
@@ -102,12 +89,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void QueueScheduledTask<T>()
|
||||
where T : IScheduledTask
|
||||
{
|
||||
QueueScheduledTask<T>(new TaskOptions());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void QueueIfNotRunning<T>()
|
||||
where T : IScheduledTask
|
||||
{
|
||||
@@ -119,6 +108,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Execute<T>()
|
||||
where T : IScheduledTask
|
||||
{
|
||||
@@ -144,11 +134,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues the scheduled task.
|
||||
/// </summary>
|
||||
/// <param name="task">The task.</param>
|
||||
/// <param name="options">The task options.</param>
|
||||
/// <inheritdoc />
|
||||
public void QueueScheduledTask(IScheduledTask task, TaskOptions options)
|
||||
{
|
||||
var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == task.GetType());
|
||||
@@ -186,10 +172,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the tasks.
|
||||
/// </summary>
|
||||
/// <param name="tasks">The tasks.</param>
|
||||
/// <inheritdoc />
|
||||
public void AddTasks(IEnumerable<IScheduledTask> tasks)
|
||||
{
|
||||
var list = tasks.Select(t => new ScheduledTaskWorker(t, _applicationPaths, this, _logger));
|
||||
@@ -197,9 +180,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
ScheduledTasks = ScheduledTasks.Concat(list).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
@@ -218,11 +199,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Cancel(IScheduledTaskWorker task)
|
||||
{
|
||||
((ScheduledTaskWorker)task).Cancel();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task Execute(IScheduledTaskWorker task, TaskOptions options)
|
||||
{
|
||||
return ((ScheduledTaskWorker)task).Execute(options);
|
||||
|
||||
Reference in New Issue
Block a user