|
@@ -6,11 +6,25 @@ using System.Threading.Tasks;
|
|
|
|
|
|
namespace Godot
|
|
namespace Godot
|
|
{
|
|
{
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// GodotTaskScheduler contains a linked list of tasks to perform as a queue. Methods
|
|
|
|
+ /// within the class are used to control the queue and perform the contained tasks.
|
|
|
|
+ /// </summary>
|
|
public class GodotTaskScheduler : TaskScheduler
|
|
public class GodotTaskScheduler : TaskScheduler
|
|
{
|
|
{
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// The current synchronization context.
|
|
|
|
+ /// </summary>
|
|
internal GodotSynchronizationContext Context { get; }
|
|
internal GodotSynchronizationContext Context { get; }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// The queue of tasks for the task scheduler.
|
|
|
|
+ /// </summary>
|
|
private readonly LinkedList<Task> _tasks = new LinkedList<Task>();
|
|
private readonly LinkedList<Task> _tasks = new LinkedList<Task>();
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Constructs a new GodotTaskScheduler instance.
|
|
|
|
+ /// </summary>
|
|
public GodotTaskScheduler()
|
|
public GodotTaskScheduler()
|
|
{
|
|
{
|
|
Context = new GodotSynchronizationContext();
|
|
Context = new GodotSynchronizationContext();
|
|
@@ -53,12 +67,19 @@ namespace Godot
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Executes all queued tasks and pending tasks from the current context.
|
|
|
|
+ /// </summary>
|
|
public void Activate()
|
|
public void Activate()
|
|
{
|
|
{
|
|
ExecuteQueuedTasks();
|
|
ExecuteQueuedTasks();
|
|
Context.ExecutePendingContinuations();
|
|
Context.ExecutePendingContinuations();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Loops through and attempts to execute each task in _tasks.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <exception cref="InvalidOperationException"></exception>
|
|
private void ExecuteQueuedTasks()
|
|
private void ExecuteQueuedTasks()
|
|
{
|
|
{
|
|
while (true)
|
|
while (true)
|