Core: CoWork now using 'nice' priority

git-svn-id: svn://ultimatepp.org/upp/trunk@11823 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-03-06 13:34:56 +00:00
commit 5a05f77912
6 changed files with 215 additions and 107 deletions

View file

@ -158,6 +158,24 @@ bool Thread::Run(Function<void ()> _cb, bool noshutdown)
return handle;
}
bool Thread::RunNice(Function<void ()> cb, bool noshutdown)
{
if(Run(cb, noshutdown)) {
Nice();
return true;
}
return false;
}
bool Thread::RunCritical(Function<void ()> cb, bool noshutdown)
{
if(Run(cb, noshutdown)) {
Critical();
return true;
}
return false;
}
Thread::~Thread()
{
Detach();
@ -363,6 +381,22 @@ void Thread::Start(Function<void ()> cb, bool noshutdown)
t.Detach();
}
void Thread::StartNice(Function<void ()> cb, bool noshutdown)
{
Thread t;
t.Run(cb);
t.Nice();
t.Detach();
}
void Thread::StartCritical(Function<void ()> cb, bool noshutdown)
{
Thread t;
t.Run(cb);
t.Critical();
t.Detach();
}
void Thread::Sleep(int msec)
{
#ifdef PLATFORM_WIN32