summaryrefslogtreecommitdiff
path: root/modules/mono/glue/cs_files/GodotTaskScheduler.cs
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2018-09-06 21:08:16 -0400
committerAaron Franke <arnfranke@yahoo.com>2018-09-10 15:12:49 -0400
commit4743852466b8393bdcbb88ef9b33d13305f26038 (patch)
treecbbd042d5aa52da9ac4cbac320d0041896608430 /modules/mono/glue/cs_files/GodotTaskScheduler.cs
parent864a3143406fe9a8023995ef5ca10758bcdd6ecd (diff)
[Mono] Tabs -> Spaces
Diffstat (limited to 'modules/mono/glue/cs_files/GodotTaskScheduler.cs')
-rw-r--r--modules/mono/glue/cs_files/GodotTaskScheduler.cs148
1 files changed, 74 insertions, 74 deletions
diff --git a/modules/mono/glue/cs_files/GodotTaskScheduler.cs b/modules/mono/glue/cs_files/GodotTaskScheduler.cs
index 3d23ec10f1..9a40fef5a9 100644
--- a/modules/mono/glue/cs_files/GodotTaskScheduler.cs
+++ b/modules/mono/glue/cs_files/GodotTaskScheduler.cs
@@ -6,89 +6,89 @@ using System.Threading.Tasks;
namespace Godot
{
- public class GodotTaskScheduler : TaskScheduler
- {
- private GodotSynchronizationContext Context { get; set; }
- private readonly LinkedList<Task> _tasks = new LinkedList<Task>();
+ public class GodotTaskScheduler : TaskScheduler
+ {
+ private GodotSynchronizationContext Context { get; set; }
+ private readonly LinkedList<Task> _tasks = new LinkedList<Task>();
- public GodotTaskScheduler()
- {
- Context = new GodotSynchronizationContext();
- SynchronizationContext.SetSynchronizationContext(Context);
- }
+ public GodotTaskScheduler()
+ {
+ Context = new GodotSynchronizationContext();
+ SynchronizationContext.SetSynchronizationContext(Context);
+ }
- protected sealed override void QueueTask(Task task)
- {
- lock (_tasks)
- {
- _tasks.AddLast(task);
- }
- }
+ protected sealed override void QueueTask(Task task)
+ {
+ lock (_tasks)
+ {
+ _tasks.AddLast(task);
+ }
+ }
- protected sealed override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
- {
- if (SynchronizationContext.Current != Context)
- {
- return false;
- }
+ protected sealed override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
+ {
+ if (SynchronizationContext.Current != Context)
+ {
+ return false;
+ }
- if (taskWasPreviouslyQueued)
- {
- TryDequeue(task);
- }
+ if (taskWasPreviouslyQueued)
+ {
+ TryDequeue(task);
+ }
- return TryExecuteTask(task);
- }
+ return TryExecuteTask(task);
+ }
- protected sealed override bool TryDequeue(Task task)
- {
- lock (_tasks)
- {
- return _tasks.Remove(task);
- }
- }
+ protected sealed override bool TryDequeue(Task task)
+ {
+ lock (_tasks)
+ {
+ return _tasks.Remove(task);
+ }
+ }
- protected sealed override IEnumerable<Task> GetScheduledTasks()
- {
- lock (_tasks)
- {
- return _tasks.ToArray();
- }
- }
+ protected sealed override IEnumerable<Task> GetScheduledTasks()
+ {
+ lock (_tasks)
+ {
+ return _tasks.ToArray();
+ }
+ }
- public void Activate()
- {
- ExecuteQueuedTasks();
- Context.ExecutePendingContinuations();
- }
+ public void Activate()
+ {
+ ExecuteQueuedTasks();
+ Context.ExecutePendingContinuations();
+ }
- private void ExecuteQueuedTasks()
- {
- while (true)
- {
- Task task;
+ private void ExecuteQueuedTasks()
+ {
+ while (true)
+ {
+ Task task;
- lock (_tasks)
- {
- if (_tasks.Any())
- {
- task = _tasks.First.Value;
- _tasks.RemoveFirst();
- }
- else
- {
- break;
- }
- }
+ lock (_tasks)
+ {
+ if (_tasks.Any())
+ {
+ task = _tasks.First.Value;
+ _tasks.RemoveFirst();
+ }
+ else
+ {
+ break;
+ }
+ }
- if (task != null)
- {
- if (!TryExecuteTask(task))
- {
- throw new InvalidOperationException();
- }
- }
- }
- }
- }
+ if (task != null)
+ {
+ if (!TryExecuteTask(task))
+ {
+ throw new InvalidOperationException();
+ }
+ }
+ }
+ }
+ }
}