Run graphics rendering on a dedicated thread.
The main game thread can offload some of the CPU cost to the rendering thread, freeing up its time to run more logic and render ticks.
This commit is contained in:
committed by
Paul Chote
parent
ea068a36f7
commit
bb536ee4fc
@@ -16,9 +16,14 @@ namespace OpenRA.Platforms.Default
|
||||
{
|
||||
abstract class ThreadAffine
|
||||
{
|
||||
readonly int managedThreadId;
|
||||
volatile int managedThreadId;
|
||||
|
||||
protected ThreadAffine()
|
||||
{
|
||||
SetThreadAffinity();
|
||||
}
|
||||
|
||||
protected void SetThreadAffinity()
|
||||
{
|
||||
managedThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||
}
|
||||
@@ -26,7 +31,7 @@ namespace OpenRA.Platforms.Default
|
||||
protected void VerifyThreadAffinity()
|
||||
{
|
||||
if (managedThreadId != Thread.CurrentThread.ManagedThreadId)
|
||||
throw new InvalidOperationException("Cross-thread operation not valid: This method must be called from the same thread that created this object.");
|
||||
throw new InvalidOperationException("Cross-thread operation not valid: This method must only be called from the thread that owns this object.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user