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.

101 lines
3.6KB

  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. #ifndef __JUCE_WAITABLEEVENT_JUCEHEADER__
  19. #define __JUCE_WAITABLEEVENT_JUCEHEADER__
  20. #include "../text/juce_String.h"
  21. //==============================================================================
  22. /**
  23. Allows threads to wait for events triggered by other threads.
  24. A thread can call wait() on a WaitableObject, and this will suspend the
  25. calling thread until another thread wakes it up by calling the signal()
  26. method.
  27. */
  28. class JUCE_API WaitableEvent
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates a WaitableEvent object. */
  33. WaitableEvent() throw();
  34. /** Destructor.
  35. If other threads are waiting on this object when it gets deleted, this
  36. can cause nasty errors, so be careful!
  37. */
  38. ~WaitableEvent() throw();
  39. //==============================================================================
  40. /** Suspends the calling thread until the event has been signalled.
  41. This will wait until the object's signal() method is called by another thread,
  42. or until the timeout expires.
  43. After the event has been signalled, this method will return true and reset
  44. the event.
  45. @param timeOutMilliseconds the maximum time to wait, in milliseconds. A negative
  46. value will cause it to wait forever.
  47. @returns true if the object has been signalled, false if the timeout expires first.
  48. @see signal, reset
  49. */
  50. bool wait (int timeOutMilliseconds = -1) const throw();
  51. //==============================================================================
  52. /** Wakes up any threads that are currently waiting on this object.
  53. If signal() is called when nothing is waiting, the next thread to call wait()
  54. will return immediately and reset the signal.
  55. @see wait, reset
  56. */
  57. void signal() const throw();
  58. //==============================================================================
  59. /** Resets the event to an unsignalled state.
  60. If it's not already signalled, this does nothing.
  61. */
  62. void reset() const throw();
  63. //==============================================================================
  64. juce_UseDebuggingNewOperator
  65. private:
  66. void* internal;
  67. WaitableEvent (const WaitableEvent&);
  68. WaitableEvent& operator= (const WaitableEvent&);
  69. };
  70. #endif // __JUCE_WAITABLEEVENT_JUCEHEADER__