Created
August 17, 2016 01:17
-
-
Save renaudbedard/d6e817a7cfa7e6c17af582014d06f835 to your computer and use it in GitHub Desktop.
The load-time GL call scheduler that FEZ 1.12 uses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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