diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-03-12 01:04:52 -0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-03-12 01:14:12 -0300 |
| commit | 7a27990faa557c5c93f52e5cb082d551ad119ed0 (patch) | |
| tree | a0800fded014a4a6afe738e5a65a17bc78cf0c19 /ChocolArm64/AThread.cs | |
| parent | 3aaa4717b6f7400bac862e589a1f345e70e78d56 (diff) | |
Allow more than one process, free resources on process dispose, implement SvcExitThread
Diffstat (limited to 'ChocolArm64/AThread.cs')
| -rw-r--r-- | ChocolArm64/AThread.cs | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/ChocolArm64/AThread.cs b/ChocolArm64/AThread.cs index cec26817..62f9d2d3 100644 --- a/ChocolArm64/AThread.cs +++ b/ChocolArm64/AThread.cs @@ -14,43 +14,30 @@ namespace ChocolArm64 private ATranslator Translator; - private ThreadPriority Priority; - private Thread Work; public event EventHandler WorkFinished; public int ThreadId => ThreadState.ThreadId; - public bool IsAlive => Work.IsAlive; - - private bool IsExecuting; + private int IsExecuting; - private object ExecuteLock; - - public AThread(ATranslator Translator, AMemory Memory, ThreadPriority Priority, long EntryPoint) + public AThread(ATranslator Translator, AMemory Memory, long EntryPoint) { this.Translator = Translator; this.Memory = Memory; - this.Priority = Priority; this.EntryPoint = EntryPoint; ThreadState = new AThreadState(); - ExecuteLock = new object(); - } - public void StopExecution() => Translator.StopExecution(); + ThreadState.Running = true; + } public bool Execute() { - lock (ExecuteLock) + if (Interlocked.Exchange(ref IsExecuting, 1) == 1) { - if (IsExecuting) - { - return false; - } - - IsExecuting = true; + return false; } Work = new Thread(delegate() @@ -62,11 +49,11 @@ namespace ChocolArm64 WorkFinished?.Invoke(this, EventArgs.Empty); }); - Work.Priority = Priority; - Work.Start(); return true; } + + public void StopExecution() => ThreadState.Running = false; } }
\ No newline at end of file |
