Skip to content

Instantly share code, notes, and snippets.

@renaudbedard
Created August 17, 2016 01:17
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save renaudbedard/d6e817a7cfa7e6c17af582014d06f835 to your computer and use it in GitHub Desktop.
The load-time GL call scheduler that FEZ 1.12 uses
using System;
using System.Collections.Concurrent;
namespace FezEngine.Tools
{
public static class DrawActionScheduler
{
static readonly ConcurrentQueue<Action> DeferredDrawActions = new ConcurrentQueue<Action>();
public static void Schedule(Action action)
{
if (!PersistentThreadPool.IsOnMainThread)
DeferredDrawActions.Enqueue(action);
else
action();
}
public static void Process()
{
Action deferredAction;
while (DeferredDrawActions.TryDequeue(out deferredAction))
deferredAction();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment