blob: c7deadae9549f50772b29d2774ff35e43e0ebd75 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
using Ryujinx.HLE.HOS.Kernel.Threading;
using System;
using System.Threading.Tasks;
namespace Ryujinx.HLE.HOS.Kernel
{
static class KernelStatic
{
[ThreadStatic]
private static KernelContext Context;
public static void YieldUntilCompletion(Action action)
{
YieldUntilCompletion(Task.Factory.StartNew(action));
}
public static void YieldUntilCompletion(Task task)
{
KThread currentThread = Context.Scheduler.GetCurrentThread();
Context.CriticalSection.Enter();
currentThread.Reschedule(ThreadSchedState.Paused);
task.ContinueWith((antecedent) =>
{
currentThread.Reschedule(ThreadSchedState.Running);
});
Context.CriticalSection.Leave();
}
internal static void SetKernelContext(KernelContext context)
{
Context = context;
}
}
}
|