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.

124 lines
3.2KB

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