The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-7 by Raw Material Software ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the
  7. GNU General Public License, as published by the Free Software Foundation;
  8. either version 2 of the License, or (at your option) any later version.
  9. JUCE is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with JUCE; if not, visit www.gnu.org/licenses or write to the
  15. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16. Boston, MA 02111-1307 USA
  17. ------------------------------------------------------------------------------
  18. If you'd like to release a closed-source product which uses JUCE, commercial
  19. licenses are also available: visit www.rawmaterialsoftware.com/juce for
  20. more information.
  21. ==============================================================================
  22. */
  23. // (This file gets included by juce_mac_NativeCode.mm, rather than being
  24. // compiled on its own).
  25. #ifdef JUCE_INCLUDED_FILE
  26. //==============================================================================
  27. /*
  28. Note that a lot of methods that you'd expect to find in this file actually
  29. live in juce_posix_SharedCode.h!
  30. */
  31. //==============================================================================
  32. void JUCE_API juce_threadEntryPoint (void*);
  33. void* threadEntryProc (void* userData) throw()
  34. {
  35. const ScopedAutoReleasePool pool;
  36. juce_threadEntryPoint (userData);
  37. return 0;
  38. }
  39. void* juce_createThread (void* userData) throw()
  40. {
  41. pthread_t handle = 0;
  42. if (pthread_create (&handle, 0, threadEntryProc, userData) == 0)
  43. {
  44. pthread_detach (handle);
  45. return (void*) handle;
  46. }
  47. return 0;
  48. }
  49. void juce_killThread (void* handle) throw()
  50. {
  51. if (handle != 0)
  52. pthread_cancel ((pthread_t) handle);
  53. }
  54. void juce_setCurrentThreadName (const String& /*name*/) throw()
  55. {
  56. }
  57. Thread::ThreadID Thread::getCurrentThreadId() throw()
  58. {
  59. return (ThreadID) pthread_self();
  60. }
  61. void juce_setThreadPriority (void* handle, int priority) throw()
  62. {
  63. if (handle == 0)
  64. handle = (void*) pthread_self();
  65. struct sched_param param;
  66. int policy;
  67. pthread_getschedparam ((pthread_t) handle, &policy, &param);
  68. param.sched_priority = jlimit (1, 127, 1 + (priority * 126) / 11);
  69. pthread_setschedparam ((pthread_t) handle, policy, &param);
  70. }
  71. void Thread::yield() throw()
  72. {
  73. sched_yield();
  74. }
  75. void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) throw()
  76. {
  77. // xxx
  78. jassertfalse
  79. }
  80. //==============================================================================
  81. bool Process::isForegroundProcess() throw()
  82. {
  83. return [NSApp isActive];
  84. }
  85. void Process::raisePrivilege()
  86. {
  87. jassertfalse
  88. }
  89. void Process::lowerPrivilege()
  90. {
  91. jassertfalse
  92. }
  93. void Process::terminate()
  94. {
  95. exit (0);
  96. }
  97. void Process::setPriority (ProcessPriority p)
  98. {
  99. // xxx
  100. }
  101. #endif