1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Thread priority fixes

This commit is contained in:
Brian Fiete 2021-06-19 12:35:29 -07:00
parent b83c70e84b
commit d998fe2229
2 changed files with 17 additions and 5 deletions

View file

@ -11,7 +11,7 @@ namespace System.Threading
public sealed class Thread public sealed class Thread
{ {
private int mInternalThread; private int mInternalThread;
private int32 mPriority; private ThreadPriority mPriority = .Normal;
public int32 mMaxStackSize; public int32 mMaxStackSize;
private String mName ~ delete _; private String mName ~ delete _;
private Delegate mDelegate; private Delegate mDelegate;
@ -67,6 +67,8 @@ namespace System.Threading
if (thread.mName != null) if (thread.mName != null)
thread.InformThreadNameChange(thread.mName); thread.InformThreadNameChange(thread.mName);
if (thread.mPriority != .Normal)
thread.SetPriorityNative((.)thread.mPriority);
int32 stackStart = 0; int32 stackStart = 0;
thread.SetStackStart((void*)&stackStart); thread.SetStackStart((void*)&stackStart);
@ -219,8 +221,18 @@ namespace System.Threading
public ThreadPriority Priority public ThreadPriority Priority
{ {
get { return (ThreadPriority)GetPriorityNative(); } get
set { SetPriorityNative((int32)value); } {
if (mInternalThread != 0)
return (ThreadPriority)GetPriorityNative();
return mPriority;
}
set
{
mPriority = value;
if (mInternalThread != 0)
SetPriorityNative((int32)value);
}
} }
[CallingConvention(.Cdecl)] [CallingConvention(.Cdecl)]
private extern int32 GetPriorityNative(); private extern int32 GetPriorityNative();

View file

@ -53,12 +53,12 @@ void Thread::SetJoinOnDelete(bool joinOnDelete)
int Thread::GetPriorityNative() int Thread::GetPriorityNative()
{ {
return (int)BfpThread_GetPriority(GetInternalThread()->mThreadHandle, NULL); return (int)BfpThread_GetPriority(GetInternalThread()->mThreadHandle, NULL) + 2;
} }
void Thread::SetPriorityNative(int priority) void Thread::SetPriorityNative(int priority)
{ {
return BfpThread_SetPriority(GetInternalThread()->mThreadHandle, (BfpThreadPriority)priority, NULL); return BfpThread_SetPriority(GetInternalThread()->mThreadHandle, (BfpThreadPriority)(priority - 2), NULL);
} }
bool Thread::GetIsAlive() bool Thread::GetIsAlive()