mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-05 03:50:07 +00:00
Merged some of the mac/linux pthread code. Fixes to the Expression class. Fix for CoreGraphics to get gradients working correctly for vertical/horizontal lines.
This commit is contained in:
parent
3e30e09afa
commit
71ee73ead1
13 changed files with 615 additions and 560 deletions
|
|
@ -32,118 +32,6 @@
|
|||
live in juce_posix_SharedCode.h!
|
||||
*/
|
||||
|
||||
//==============================================================================
|
||||
void JUCE_API juce_threadEntryPoint (void*);
|
||||
|
||||
void* threadEntryProc (void* value)
|
||||
{
|
||||
juce_threadEntryPoint (value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* juce_createThread (void* userData)
|
||||
{
|
||||
pthread_t handle = 0;
|
||||
|
||||
if (pthread_create (&handle, 0, threadEntryProc, userData) == 0)
|
||||
{
|
||||
pthread_detach (handle);
|
||||
return (void*) handle;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void juce_killThread (void* handle)
|
||||
{
|
||||
if (handle != 0)
|
||||
pthread_cancel ((pthread_t) handle);
|
||||
}
|
||||
|
||||
void juce_setCurrentThreadName (const String& /*name*/)
|
||||
{
|
||||
}
|
||||
|
||||
Thread::ThreadID Thread::getCurrentThreadId()
|
||||
{
|
||||
return (ThreadID) pthread_self();
|
||||
}
|
||||
|
||||
/* This is all a bit non-ideal... the trouble is that on Linux you
|
||||
need to call setpriority to affect the dynamic priority for
|
||||
non-realtime processes, but this requires the pid, which is not
|
||||
accessible from the pthread_t. We could get it by calling getpid
|
||||
once each thread has started, but then we would need a list of
|
||||
running threads etc etc.
|
||||
Also there is no such thing as IDLE priority on Linux.
|
||||
For the moment, map idle, low and normal process priorities to
|
||||
SCHED_OTHER, with the thread priority ignored for these classes.
|
||||
Map high priority processes to the lower half of the SCHED_RR
|
||||
range, and realtime to the upper half.
|
||||
|
||||
priority 1 to 10 where 5=normal, 1=low. If the handle is 0, sets the
|
||||
priority of the current thread
|
||||
*/
|
||||
bool juce_setThreadPriority (void* handle, int priority)
|
||||
{
|
||||
struct sched_param param;
|
||||
int policy;
|
||||
|
||||
if (handle == 0)
|
||||
handle = (void*) pthread_self();
|
||||
|
||||
if (pthread_getschedparam ((pthread_t) handle, &policy, ¶m) == 0
|
||||
&& policy != SCHED_OTHER)
|
||||
{
|
||||
param.sched_priority = jlimit (1, 127, 1 + (priority * 126) / 11);
|
||||
return pthread_setschedparam ((pthread_t) handle, policy, ¶m) == 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Remove this macro if you're having problems compiling the cpu affinity
|
||||
calls (the API for these has changed about quite a bit in various Linux
|
||||
versions, and a lot of distros seem to ship with obsolete versions)
|
||||
*/
|
||||
#if defined (CPU_ISSET) && ! defined (SUPPORT_AFFINITIES)
|
||||
#define SUPPORT_AFFINITIES 1
|
||||
#endif
|
||||
|
||||
void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask)
|
||||
{
|
||||
#if SUPPORT_AFFINITIES
|
||||
cpu_set_t affinity;
|
||||
CPU_ZERO (&affinity);
|
||||
|
||||
for (int i = 0; i < 32; ++i)
|
||||
if ((affinityMask & (1 << i)) != 0)
|
||||
CPU_SET (i, &affinity);
|
||||
|
||||
/*
|
||||
N.B. If this line causes a compile error, then you've probably not got the latest
|
||||
version of glibc installed.
|
||||
|
||||
If you don't want to update your copy of glibc and don't care about cpu affinities,
|
||||
then you can just disable all this stuff by setting the SUPPORT_AFFINITIES macro to 0.
|
||||
*/
|
||||
sched_setaffinity (getpid(), sizeof (cpu_set_t), &affinity);
|
||||
sched_yield();
|
||||
|
||||
#else
|
||||
/* affinities aren't supported because either the appropriate header files weren't found,
|
||||
or the SUPPORT_AFFINITIES macro was turned off
|
||||
*/
|
||||
jassertfalse;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Thread::yield()
|
||||
{
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// sets the process to 0=low priority, 1=normal, 2=high, 3=realtime
|
||||
void Process::setPriority (ProcessPriority prior)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue