| @@ -91,9 +91,9 @@ void juce_setCurrentThreadName (const String& /*name*/) throw() | |||
| { | |||
| } | |||
| int64 Thread::getCurrentThreadId() throw() | |||
| Thread::ThreadID Thread::getCurrentThreadId() throw() | |||
| { | |||
| return pthread_self(); | |||
| return (ThreadID) pthread_self(); | |||
| } | |||
| /* | |||
| @@ -380,7 +380,7 @@ const StringArray AudioCDBurner::findAvailableDevices() | |||
| NSArray* names = findDiskBurnerDevices(); | |||
| StringArray s; | |||
| for (int i = 0; i < [names count]; ++i) | |||
| for (unsigned int i = 0; i < [names count]; ++i) | |||
| s.add (String::fromUTF8 ((JUCE_NAMESPACE::uint8*) [[names objectAtIndex: i] UTF8String])); | |||
| return s; | |||
| @@ -74,22 +74,22 @@ class CoreAudioInternal : public Timer | |||
| public: | |||
| //============================================================================== | |||
| CoreAudioInternal (AudioDeviceID id) | |||
| : deviceID (id), | |||
| started (false), | |||
| audioBuffer (0), | |||
| numInputChans (0), | |||
| numOutputChans (0), | |||
| callbacksAllowed (true), | |||
| numInputChannelInfos (0), | |||
| numOutputChannelInfos (0), | |||
| inputLatency (0), | |||
| : inputLatency (0), | |||
| outputLatency (0), | |||
| callback (0), | |||
| #if ! MACOS_10_4_OR_EARLIER | |||
| audioProcID (0), | |||
| #endif | |||
| inputDevice (0), | |||
| isSlaveDevice (false) | |||
| isSlaveDevice (false), | |||
| deviceID (id), | |||
| started (false), | |||
| audioBuffer (0), | |||
| numInputChans (0), | |||
| numOutputChans (0), | |||
| callbacksAllowed (true), | |||
| numInputChannelInfos (0), | |||
| numOutputChannelInfos (0) | |||
| { | |||
| sampleRate = 0; | |||
| bufferSize = 512; | |||
| @@ -391,7 +391,7 @@ public: | |||
| if (types != 0) | |||
| { | |||
| if (((unsigned int) index) < num) | |||
| if (((unsigned int) index) < (unsigned int) num) | |||
| { | |||
| OSType typeId = types[index]; | |||
| AudioDeviceSetProperty (deviceID, 0, 0, input, kAudioDevicePropertyDataSource, sizeof (typeId), &typeId); | |||
| @@ -138,7 +138,7 @@ void FileChooser::showPlatformDialog (OwnedArray<File>& results, | |||
| { | |||
| NSOpenPanel* openPanel = (NSOpenPanel*) panel; | |||
| NSArray* urls = [openPanel filenames]; | |||
| for (int i = 0; i < [urls count]; ++i) | |||
| for (unsigned int i = 0; i < [urls count]; ++i) | |||
| { | |||
| NSString* f = [urls objectAtIndex: i]; | |||
| results.add (new File (nsStringToJuce (f))); | |||
| @@ -348,7 +348,7 @@ struct FindFileStruct | |||
| if (fnmatch (wildCardUTF8, de->d_name, 0) == 0) | |||
| { | |||
| result = PlatformUtilities::convertToPrecomposedUnicode (String::fromUTF8 ((const uint8*) de->d_name)); | |||
| result = String::fromUTF8 ((const uint8*) de->d_name); | |||
| const String path (parentDir + result); | |||
| @@ -84,7 +84,7 @@ public: | |||
| virtual void openFiles (NSArray* filenames) | |||
| { | |||
| StringArray files; | |||
| for (int i = 0; i < [filenames count]; ++i) | |||
| for (unsigned int i = 0; i < [filenames count]; ++i) | |||
| files.add (nsStringToJuce ((NSString*) [filenames objectAtIndex: i])); | |||
| if (files.size() > 0 && JUCEApplication::getInstance() != 0) | |||
| @@ -219,7 +219,7 @@ void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords, const bool c | |||
| NSArray* screens = [NSScreen screens]; | |||
| const float mainScreenBottom = [[NSScreen mainScreen] frame].size.height; | |||
| for (int i = 0; i < [screens count]; ++i) | |||
| for (unsigned int i = 0; i < [screens count]; ++i) | |||
| { | |||
| NSScreen* s = (NSScreen*) [screens objectAtIndex: i]; | |||
| @@ -47,8 +47,8 @@ public: | |||
| NSViewComponentInternal (NSView* view_, Component* const owner_) | |||
| : ComponentMovementWatcher (owner_), | |||
| owner (owner_), | |||
| wasShowing (false), | |||
| currentPeer (0), | |||
| wasShowing (false), | |||
| view (view_) | |||
| { | |||
| [view retain]; | |||
| @@ -664,8 +664,8 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component, | |||
| const int windowStyleFlags, | |||
| NSView* viewToAttachTo) | |||
| : ComponentPeer (component, windowStyleFlags), | |||
| view (0), | |||
| window (0) | |||
| window (0), | |||
| view (0) | |||
| { | |||
| NSRect r; | |||
| r.origin.x = 0; | |||
| @@ -1266,7 +1266,7 @@ BOOL NSViewComponentPeer::sendDragCallback (int type, id <NSDraggingInfo> sender | |||
| { | |||
| NSArray* items = (NSArray*) list; | |||
| for (int i = 0; i < [items count]; ++i) | |||
| for (unsigned int i = 0; i < [items count]; ++i) | |||
| files.add (nsStringToJuce ((NSString*) [items objectAtIndex: i])); | |||
| } | |||
| @@ -148,7 +148,7 @@ const String PlatformUtilities::convertToPrecomposedUnicode (const String& s) | |||
| tchar* t = const_cast <tchar*> ((const tchar*) result); | |||
| int i; | |||
| unsigned int i; | |||
| for (i = 0; i < bytesRead / sizeof (UniChar); ++i) | |||
| t[i] = (tchar) tempOut[i]; | |||
| @@ -284,8 +284,7 @@ int64 Time::getHighResolutionTicksPerSecond() throw() | |||
| int64 SystemStats::getClockCycleCounter() throw() | |||
| { | |||
| jassertfalse | |||
| return 0; | |||
| return (int64) AudioGetCurrentHostTime(); | |||
| } | |||
| bool Time::setSystemTimeToThisTime() const throw() | |||
| @@ -72,9 +72,9 @@ void juce_setCurrentThreadName (const String& /*name*/) throw() | |||
| { | |||
| } | |||
| int64 Thread::getCurrentThreadId() throw() | |||
| Thread::ThreadID Thread::getCurrentThreadId() throw() | |||
| { | |||
| return (int64) pthread_self(); | |||
| return (ThreadID) pthread_self(); | |||
| } | |||
| void juce_setThreadPriority (void* handle, int priority) throw() | |||
| @@ -168,9 +168,9 @@ void juce_setCurrentThreadName (const String& name) throw() | |||
| #endif | |||
| } | |||
| int64 Thread::getCurrentThreadId() throw() | |||
| Thread::ThreadID Thread::getCurrentThreadId() throw() | |||
| { | |||
| return (int) GetCurrentThreadId(); | |||
| return (ThreadID) GetCurrentThreadId(); | |||
| } | |||
| // priority 1 to 10 where 5=normal, 1=low | |||
| @@ -40,7 +40,7 @@ class BouncingBallComp : public Component, | |||
| float innerX, innerY; | |||
| Colour colour; | |||
| CriticalSection lock; | |||
| int64 threadId; | |||
| Thread::ThreadID threadId; | |||
| public: | |||
| BouncingBallComp() | |||
| @@ -79,7 +79,7 @@ public: | |||
| g.setColour (Colours::black); | |||
| g.setFont (10.0f); | |||
| g.drawText (String::toHexString (threadId), 0, 0, getWidth(), getHeight(), Justification::centred, false); | |||
| g.drawText (String::toHexString ((int64) threadId), 0, 0, getWidth(), getHeight(), Justification::centred, false); | |||
| } | |||
| void parentSizeChanged() | |||
| @@ -40,7 +40,7 @@ class BouncingBallComp : public Component, | |||
| float innerX, innerY; | |||
| Colour colour; | |||
| CriticalSection lock; | |||
| int64 threadId; | |||
| Thread::ThreadID threadId; | |||
| public: | |||
| BouncingBallComp() | |||
| @@ -79,7 +79,7 @@ public: | |||
| g.setColour (Colours::black); | |||
| g.setFont (10.0f); | |||
| g.drawText (String::toHexString (threadId), 0, 0, getWidth(), getHeight(), Justification::centred, false); | |||
| g.drawText (String::toHexString ((int64) threadId), 0, 0, getWidth(), getHeight(), Justification::centred, false); | |||
| } | |||
| void parentSizeChanged() | |||
| @@ -14282,7 +14282,7 @@ ReadWriteLock::~ReadWriteLock() throw() | |||
| void ReadWriteLock::enterRead() const throw() | |||
| { | |||
| const int64 threadId = Thread::getCurrentThreadId(); | |||
| const Thread::ThreadID threadId = Thread::getCurrentThreadId(); | |||
| const ScopedLock sl (accessLock); | |||
| for (;;) | |||
| @@ -14300,12 +14300,12 @@ void ReadWriteLock::enterRead() const throw() | |||
| { | |||
| if (i < readerThreads.size()) | |||
| { | |||
| readerThreads.set (i + 1, readerThreads.getUnchecked (i + 1) + 1); | |||
| readerThreads.set (i + 1, (Thread::ThreadID) (1 + (pointer_sized_int) readerThreads.getUnchecked (i + 1))); | |||
| } | |||
| else | |||
| { | |||
| readerThreads.add (threadId); | |||
| readerThreads.add (1); | |||
| readerThreads.add ((Thread::ThreadID) 1); | |||
| } | |||
| return; | |||
| @@ -14318,14 +14318,14 @@ void ReadWriteLock::enterRead() const throw() | |||
| void ReadWriteLock::exitRead() const throw() | |||
| { | |||
| const int64 threadId = Thread::getCurrentThreadId(); | |||
| const Thread::ThreadID threadId = Thread::getCurrentThreadId(); | |||
| const ScopedLock sl (accessLock); | |||
| for (int i = 0; i < readerThreads.size(); i += 2) | |||
| { | |||
| if (readerThreads.getUnchecked(i) == threadId) | |||
| { | |||
| const int newCount = ((int) readerThreads.getUnchecked (i + 1)) - 1; | |||
| const int newCount = ((int) (Thread::ThreadID) readerThreads.getUnchecked (i + 1)) - 1; | |||
| if (newCount == 0) | |||
| { | |||
| @@ -14334,7 +14334,7 @@ void ReadWriteLock::exitRead() const throw() | |||
| } | |||
| else | |||
| { | |||
| readerThreads.set (i + 1, newCount); | |||
| readerThreads.set (i + 1, (Thread::ThreadID) (pointer_sized_int) newCount); | |||
| } | |||
| return; | |||
| @@ -14346,7 +14346,7 @@ void ReadWriteLock::exitRead() const throw() | |||
| void ReadWriteLock::enterWrite() const throw() | |||
| { | |||
| const int64 threadId = Thread::getCurrentThreadId(); | |||
| const Thread::ThreadID threadId = Thread::getCurrentThreadId(); | |||
| const ScopedLock sl (accessLock); | |||
| for (;;) | |||
| @@ -14371,7 +14371,7 @@ void ReadWriteLock::enterWrite() const throw() | |||
| bool ReadWriteLock::tryEnterWrite() const throw() | |||
| { | |||
| const int64 threadId = Thread::getCurrentThreadId(); | |||
| const Thread::ThreadID threadId = Thread::getCurrentThreadId(); | |||
| const ScopedLock sl (accessLock); | |||
| if (readerThreads.size() + numWriters == 0 | |||
| @@ -14587,7 +14587,7 @@ void Thread::setAffinityMask (const uint32 affinityMask) throw() | |||
| affinityMask_ = affinityMask; | |||
| } | |||
| int64 Thread::getThreadId() const throw() | |||
| Thread::ThreadID Thread::getThreadId() const throw() | |||
| { | |||
| return threadId_; | |||
| } | |||
| @@ -14609,7 +14609,7 @@ int Thread::getNumRunningThreads() throw() | |||
| Thread* Thread::getCurrentThread() throw() | |||
| { | |||
| const int64 thisId = getCurrentThreadId(); | |||
| const ThreadID thisId = getCurrentThreadId(); | |||
| Thread* result = 0; | |||
| runningThreadsLock.enter(); | |||
| @@ -19250,7 +19250,8 @@ private: | |||
| const int trackNum; | |||
| double trackUnitsPerFrame; | |||
| int samplesPerFrame; | |||
| int lastSampleRead, lastThreadId; | |||
| int lastSampleRead; | |||
| Thread::ThreadID lastThreadId; | |||
| MovieAudioExtractionRef extractor; | |||
| AudioStreamBasicDescription inputStreamDesc; | |||
| AudioBufferList* bufferList; | |||
| @@ -36447,7 +36448,7 @@ bool MessageManager::isThisTheMessageThread() const throw() | |||
| return Thread::getCurrentThreadId() == messageThreadId; | |||
| } | |||
| void MessageManager::setCurrentMessageThread (const int64 threadId) throw() | |||
| void MessageManager::setCurrentMessageThread (const Thread::ThreadID threadId) throw() | |||
| { | |||
| messageThreadId = threadId; | |||
| } | |||
| @@ -239374,9 +239375,9 @@ void juce_setCurrentThreadName (const String& name) throw() | |||
| #endif | |||
| } | |||
| int64 Thread::getCurrentThreadId() throw() | |||
| Thread::ThreadID Thread::getCurrentThreadId() throw() | |||
| { | |||
| return (int) GetCurrentThreadId(); | |||
| return (ThreadID) GetCurrentThreadId(); | |||
| } | |||
| // priority 1 to 10 where 5=normal, 1=low | |||
| @@ -255237,9 +255238,9 @@ void juce_setCurrentThreadName (const String& /*name*/) throw() | |||
| { | |||
| } | |||
| int64 Thread::getCurrentThreadId() throw() | |||
| Thread::ThreadID Thread::getCurrentThreadId() throw() | |||
| { | |||
| return pthread_self(); | |||
| return (ThreadID) pthread_self(); | |||
| } | |||
| /* | |||
| @@ -262574,7 +262575,7 @@ const String PlatformUtilities::convertToPrecomposedUnicode (const String& s) | |||
| tchar* t = const_cast <tchar*> ((const tchar*) result); | |||
| int i; | |||
| unsigned int i; | |||
| for (i = 0; i < bytesRead / sizeof (UniChar); ++i) | |||
| t[i] = (tchar) tempOut[i]; | |||
| @@ -263356,9 +263357,9 @@ void juce_setCurrentThreadName (const String& /*name*/) throw() | |||
| { | |||
| } | |||
| int64 Thread::getCurrentThreadId() throw() | |||
| Thread::ThreadID Thread::getCurrentThreadId() throw() | |||
| { | |||
| return (int64) pthread_self(); | |||
| return (ThreadID) pthread_self(); | |||
| } | |||
| void juce_setThreadPriority (void* handle, int priority) throw() | |||
| @@ -264512,7 +264513,7 @@ void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords, const bool c | |||
| NSArray* screens = [NSScreen screens]; | |||
| const float mainScreenBottom = [[NSScreen mainScreen] frame].size.height; | |||
| for (int i = 0; i < [screens count]; ++i) | |||
| for (unsigned int i = 0; i < [screens count]; ++i) | |||
| { | |||
| NSScreen* s = (NSScreen*) [screens objectAtIndex: i]; | |||
| @@ -265195,8 +265196,8 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component, | |||
| const int windowStyleFlags, | |||
| NSView* viewToAttachTo) | |||
| : ComponentPeer (component, windowStyleFlags), | |||
| view (0), | |||
| window (0) | |||
| window (0), | |||
| view (0) | |||
| { | |||
| NSRect r; | |||
| r.origin.x = 0; | |||
| @@ -265793,7 +265794,7 @@ BOOL NSViewComponentPeer::sendDragCallback (int type, id <NSDraggingInfo> sender | |||
| { | |||
| NSArray* items = (NSArray*) list; | |||
| for (int i = 0; i < [items count]; ++i) | |||
| for (unsigned int i = 0; i < [items count]; ++i) | |||
| files.add (nsStringToJuce ((NSString*) [items objectAtIndex: i])); | |||
| } | |||
| @@ -266166,8 +266167,8 @@ public: | |||
| NSViewComponentInternal (NSView* view_, Component* const owner_) | |||
| : ComponentMovementWatcher (owner_), | |||
| owner (owner_), | |||
| wasShowing (false), | |||
| currentPeer (0), | |||
| wasShowing (false), | |||
| view (view_) | |||
| { | |||
| [view retain]; | |||
| @@ -267251,7 +267252,7 @@ void FileChooser::showPlatformDialog (OwnedArray<File>& results, | |||
| { | |||
| NSOpenPanel* openPanel = (NSOpenPanel*) panel; | |||
| NSArray* urls = [openPanel filenames]; | |||
| for (int i = 0; i < [urls count]; ++i) | |||
| for (unsigned int i = 0; i < [urls count]; ++i) | |||
| { | |||
| NSString* f = [urls objectAtIndex: i]; | |||
| results.add (new File (nsStringToJuce (f))); | |||
| @@ -267875,7 +267876,7 @@ const StringArray AudioCDBurner::findAvailableDevices() | |||
| NSArray* names = findDiskBurnerDevices(); | |||
| StringArray s; | |||
| for (int i = 0; i < [names count]; ++i) | |||
| for (unsigned int i = 0; i < [names count]; ++i) | |||
| s.add (String::fromUTF8 ((JUCE_NAMESPACE::uint8*) [[names objectAtIndex: i] UTF8String])); | |||
| return s; | |||
| @@ -268487,7 +268488,7 @@ public: | |||
| virtual void openFiles (NSArray* filenames) | |||
| { | |||
| StringArray files; | |||
| for (int i = 0; i < [filenames count]; ++i) | |||
| for (unsigned int i = 0; i < [filenames count]; ++i) | |||
| files.add (nsStringToJuce ((NSString*) [filenames objectAtIndex: i])); | |||
| if (files.size() > 0 && JUCEApplication::getInstance() != 0) | |||
| @@ -269010,22 +269011,22 @@ class CoreAudioInternal : public Timer | |||
| public: | |||
| CoreAudioInternal (AudioDeviceID id) | |||
| : deviceID (id), | |||
| started (false), | |||
| audioBuffer (0), | |||
| numInputChans (0), | |||
| numOutputChans (0), | |||
| callbacksAllowed (true), | |||
| numInputChannelInfos (0), | |||
| numOutputChannelInfos (0), | |||
| inputLatency (0), | |||
| : inputLatency (0), | |||
| outputLatency (0), | |||
| callback (0), | |||
| #if ! MACOS_10_4_OR_EARLIER | |||
| audioProcID (0), | |||
| #endif | |||
| inputDevice (0), | |||
| isSlaveDevice (false) | |||
| isSlaveDevice (false), | |||
| deviceID (id), | |||
| started (false), | |||
| audioBuffer (0), | |||
| numInputChans (0), | |||
| numOutputChans (0), | |||
| callbacksAllowed (true), | |||
| numInputChannelInfos (0), | |||
| numOutputChannelInfos (0) | |||
| { | |||
| sampleRate = 0; | |||
| bufferSize = 512; | |||
| @@ -269326,7 +269327,7 @@ public: | |||
| if (types != 0) | |||
| { | |||
| if (((unsigned int) index) < num) | |||
| if (((unsigned int) index) < (unsigned int) num) | |||
| { | |||
| OSType typeId = types[index]; | |||
| AudioDeviceSetProperty (deviceID, 0, 0, input, kAudioDevicePropertyDataSource, sizeof (typeId), &typeId); | |||
| @@ -13940,6 +13940,255 @@ private: | |||
| #endif // __JUCE_WAITABLEEVENT_JUCEHEADER__ | |||
| /********* End of inlined file: juce_WaitableEvent.h *********/ | |||
| /********* Start of inlined file: juce_Thread.h *********/ | |||
| #ifndef __JUCE_THREAD_JUCEHEADER__ | |||
| #define __JUCE_THREAD_JUCEHEADER__ | |||
| /** | |||
| Encapsulates a thread. | |||
| Subclasses derive from Thread and implement the run() method, in which they | |||
| do their business. The thread can then be started with the startThread() method | |||
| and controlled with various other methods. | |||
| This class also contains some thread-related static methods, such | |||
| as sleep(), yield(), getCurrentThreadId() etc. | |||
| @see CriticalSection, WaitableEvent, Process, ThreadWithProgressWindow, | |||
| MessageManagerLock | |||
| */ | |||
| class JUCE_API Thread | |||
| { | |||
| public: | |||
| /** | |||
| Creates a thread. | |||
| When first created, the thread is not running. Use the startThread() | |||
| method to start it. | |||
| */ | |||
| Thread (const String& threadName); | |||
| /** Destructor. | |||
| Deleting a Thread object that is running will only give the thread a | |||
| brief opportunity to stop itself cleanly, so it's recommended that you | |||
| should always call stopThread() with a decent timeout before deleting, | |||
| to avoid the thread being forcibly killed (which is a Bad Thing). | |||
| */ | |||
| virtual ~Thread(); | |||
| /** Must be implemented to perform the thread's actual code. | |||
| Remember that the thread must regularly check the threadShouldExit() | |||
| method whilst running, and if this returns true it should return from | |||
| the run() method as soon as possible to avoid being forcibly killed. | |||
| @see threadShouldExit, startThread | |||
| */ | |||
| virtual void run() = 0; | |||
| // Thread control functions.. | |||
| /** Starts the thread running. | |||
| This will start the thread's run() method. | |||
| (if it's already started, startThread() won't do anything). | |||
| @see stopThread | |||
| */ | |||
| void startThread() throw(); | |||
| /** Starts the thread with a given priority. | |||
| Launches the thread with a given priority, where 0 = lowest, 10 = highest. | |||
| If the thread is already running, its priority will be changed. | |||
| @see startThread, setPriority | |||
| */ | |||
| void startThread (const int priority) throw(); | |||
| /** Attempts to stop the thread running. | |||
| This method will cause the threadShouldExit() method to return true | |||
| and call notify() in case the thread is currently waiting. | |||
| Hopefully the thread will then respond to this by exiting cleanly, and | |||
| the stopThread method will wait for a given time-period for this to | |||
| happen. | |||
| If the thread is stuck and fails to respond after the time-out, it gets | |||
| forcibly killed, which is a very bad thing to happen, as it could still | |||
| be holding locks, etc. which are needed by other parts of your program. | |||
| @param timeOutMilliseconds The number of milliseconds to wait for the | |||
| thread to finish before killing it by force. A negative | |||
| value in here will wait forever. | |||
| @see signalThreadShouldExit, threadShouldExit, waitForThreadToExit, isThreadRunning | |||
| */ | |||
| void stopThread (const int timeOutMilliseconds) throw(); | |||
| /** Returns true if the thread is currently active */ | |||
| bool isThreadRunning() const throw(); | |||
| /** Sets a flag to tell the thread it should stop. | |||
| Calling this means that the threadShouldExit() method will then return true. | |||
| The thread should be regularly checking this to see whether it should exit. | |||
| @see threadShouldExit | |||
| @see waitForThreadToExit | |||
| */ | |||
| void signalThreadShouldExit() throw(); | |||
| /** Checks whether the thread has been told to stop running. | |||
| Threads need to check this regularly, and if it returns true, they should | |||
| return from their run() method at the first possible opportunity. | |||
| @see signalThreadShouldExit | |||
| */ | |||
| inline bool threadShouldExit() const throw() { return threadShouldExit_; } | |||
| /** Waits for the thread to stop. | |||
| This will waits until isThreadRunning() is false or until a timeout expires. | |||
| @param timeOutMilliseconds the time to wait, in milliseconds. If this value | |||
| is less than zero, it will wait forever. | |||
| @returns true if the thread exits, or false if the timeout expires first. | |||
| */ | |||
| bool waitForThreadToExit (const int timeOutMilliseconds) const throw(); | |||
| /** Changes the thread's priority. | |||
| @param priority the new priority, in the range 0 (lowest) to 10 (highest). A priority | |||
| of 5 is normal. | |||
| */ | |||
| void setPriority (const int priority) throw(); | |||
| /** Changes the priority of the caller thread. | |||
| Similar to setPriority(), but this static method acts on the caller thread. | |||
| @see setPriority | |||
| */ | |||
| static void setCurrentThreadPriority (const int priority) throw(); | |||
| /** Sets the affinity mask for the thread. | |||
| This will only have an effect next time the thread is started - i.e. if the | |||
| thread is already running when called, it'll have no effect. | |||
| @see setCurrentThreadAffinityMask | |||
| */ | |||
| void setAffinityMask (const uint32 affinityMask) throw(); | |||
| /** Changes the affinity mask for the caller thread. | |||
| This will change the affinity mask for the thread that calls this static method. | |||
| @see setAffinityMask | |||
| */ | |||
| static void setCurrentThreadAffinityMask (const uint32 affinityMask) throw(); | |||
| // this can be called from any thread that needs to pause.. | |||
| static void JUCE_CALLTYPE sleep (int milliseconds) throw(); | |||
| /** Yields the calling thread's current time-slot. */ | |||
| static void JUCE_CALLTYPE yield() throw(); | |||
| /** Makes the thread wait for a notification. | |||
| This puts the thread to sleep until either the timeout period expires, or | |||
| another thread calls the notify() method to wake it up. | |||
| @returns true if the event has been signalled, false if the timeout expires. | |||
| */ | |||
| bool wait (const int timeOutMilliseconds) const throw(); | |||
| /** Wakes up the thread. | |||
| If the thread has called the wait() method, this will wake it up. | |||
| @see wait | |||
| */ | |||
| void notify() const throw(); | |||
| /** A value type used for thread IDs. | |||
| @see getCurrentThreadId(), getThreadId() | |||
| */ | |||
| typedef void* ThreadID; | |||
| /** Returns an id that identifies the caller thread. | |||
| To find the ID of a particular thread object, use getThreadId(). | |||
| @returns a unique identifier that identifies the calling thread. | |||
| @see getThreadId | |||
| */ | |||
| static ThreadID getCurrentThreadId() throw(); | |||
| /** Finds the thread object that is currently running. | |||
| Note that the main UI thread (or other non-Juce threads) don't have a Thread | |||
| object associated with them, so this will return 0. | |||
| */ | |||
| static Thread* getCurrentThread() throw(); | |||
| /** Returns the ID of this thread. | |||
| That means the ID of this thread object - not of the thread that's calling the method. | |||
| This can change when the thread is started and stopped, and will be invalid if the | |||
| thread's not actually running. | |||
| @see getCurrentThreadId | |||
| */ | |||
| ThreadID getThreadId() const throw(); | |||
| /** Returns the name of the thread. | |||
| This is the name that gets set in the constructor. | |||
| */ | |||
| const String getThreadName() const throw() { return threadName_; } | |||
| /** Returns the number of currently-running threads. | |||
| @returns the number of Thread objects known to be currently running. | |||
| @see stopAllThreads | |||
| */ | |||
| static int getNumRunningThreads() throw(); | |||
| /** Tries to stop all currently-running threads. | |||
| This will attempt to stop all the threads known to be running at the moment. | |||
| */ | |||
| static void stopAllThreads (const int timeoutInMillisecs) throw(); | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| const String threadName_; | |||
| void* volatile threadHandle_; | |||
| CriticalSection startStopLock; | |||
| WaitableEvent startSuspensionEvent_, defaultEvent_; | |||
| int threadPriority_; | |||
| ThreadID threadId_; | |||
| uint32 affinityMask_; | |||
| bool volatile threadShouldExit_; | |||
| friend void JUCE_API juce_threadEntryPoint (void*); | |||
| static void threadEntryPoint (Thread* thread) throw(); | |||
| Thread (const Thread&); | |||
| const Thread& operator= (const Thread&); | |||
| }; | |||
| #endif // __JUCE_THREAD_JUCEHEADER__ | |||
| /********* End of inlined file: juce_Thread.h *********/ | |||
| /** | |||
| A critical section that allows multiple simultaneous readers. | |||
| @@ -14033,8 +14282,8 @@ private: | |||
| CriticalSection accessLock; | |||
| WaitableEvent waitEvent; | |||
| mutable int numWaitingWriters, numWriters; | |||
| mutable int64 writerThreadId; | |||
| mutable Array <int64> readerThreads; | |||
| mutable Thread::ThreadID writerThreadId; | |||
| mutable Array <Thread::ThreadID> readerThreads; | |||
| ReadWriteLock (const ReadWriteLock&); | |||
| const ReadWriteLock& operator= (const ReadWriteLock&); | |||
| @@ -14260,250 +14509,6 @@ private: | |||
| #endif | |||
| #ifndef __JUCE_THREAD_JUCEHEADER__ | |||
| /********* Start of inlined file: juce_Thread.h *********/ | |||
| #ifndef __JUCE_THREAD_JUCEHEADER__ | |||
| #define __JUCE_THREAD_JUCEHEADER__ | |||
| /** | |||
| Encapsulates a thread. | |||
| Subclasses derive from Thread and implement the run() method, in which they | |||
| do their business. The thread can then be started with the startThread() method | |||
| and controlled with various other methods. | |||
| This class also contains some thread-related static methods, such | |||
| as sleep(), yield(), getCurrentThreadId() etc. | |||
| @see CriticalSection, WaitableEvent, Process, ThreadWithProgressWindow, | |||
| MessageManagerLock | |||
| */ | |||
| class JUCE_API Thread | |||
| { | |||
| public: | |||
| /** | |||
| Creates a thread. | |||
| When first created, the thread is not running. Use the startThread() | |||
| method to start it. | |||
| */ | |||
| Thread (const String& threadName); | |||
| /** Destructor. | |||
| Deleting a Thread object that is running will only give the thread a | |||
| brief opportunity to stop itself cleanly, so it's recommended that you | |||
| should always call stopThread() with a decent timeout before deleting, | |||
| to avoid the thread being forcibly killed (which is a Bad Thing). | |||
| */ | |||
| virtual ~Thread(); | |||
| /** Must be implemented to perform the thread's actual code. | |||
| Remember that the thread must regularly check the threadShouldExit() | |||
| method whilst running, and if this returns true it should return from | |||
| the run() method as soon as possible to avoid being forcibly killed. | |||
| @see threadShouldExit, startThread | |||
| */ | |||
| virtual void run() = 0; | |||
| // Thread control functions.. | |||
| /** Starts the thread running. | |||
| This will start the thread's run() method. | |||
| (if it's already started, startThread() won't do anything). | |||
| @see stopThread | |||
| */ | |||
| void startThread() throw(); | |||
| /** Starts the thread with a given priority. | |||
| Launches the thread with a given priority, where 0 = lowest, 10 = highest. | |||
| If the thread is already running, its priority will be changed. | |||
| @see startThread, setPriority | |||
| */ | |||
| void startThread (const int priority) throw(); | |||
| /** Attempts to stop the thread running. | |||
| This method will cause the threadShouldExit() method to return true | |||
| and call notify() in case the thread is currently waiting. | |||
| Hopefully the thread will then respond to this by exiting cleanly, and | |||
| the stopThread method will wait for a given time-period for this to | |||
| happen. | |||
| If the thread is stuck and fails to respond after the time-out, it gets | |||
| forcibly killed, which is a very bad thing to happen, as it could still | |||
| be holding locks, etc. which are needed by other parts of your program. | |||
| @param timeOutMilliseconds The number of milliseconds to wait for the | |||
| thread to finish before killing it by force. A negative | |||
| value in here will wait forever. | |||
| @see signalThreadShouldExit, threadShouldExit, waitForThreadToExit, isThreadRunning | |||
| */ | |||
| void stopThread (const int timeOutMilliseconds) throw(); | |||
| /** Returns true if the thread is currently active */ | |||
| bool isThreadRunning() const throw(); | |||
| /** Sets a flag to tell the thread it should stop. | |||
| Calling this means that the threadShouldExit() method will then return true. | |||
| The thread should be regularly checking this to see whether it should exit. | |||
| @see threadShouldExit | |||
| @see waitForThreadToExit | |||
| */ | |||
| void signalThreadShouldExit() throw(); | |||
| /** Checks whether the thread has been told to stop running. | |||
| Threads need to check this regularly, and if it returns true, they should | |||
| return from their run() method at the first possible opportunity. | |||
| @see signalThreadShouldExit | |||
| */ | |||
| inline bool threadShouldExit() const throw() { return threadShouldExit_; } | |||
| /** Waits for the thread to stop. | |||
| This will waits until isThreadRunning() is false or until a timeout expires. | |||
| @param timeOutMilliseconds the time to wait, in milliseconds. If this value | |||
| is less than zero, it will wait forever. | |||
| @returns true if the thread exits, or false if the timeout expires first. | |||
| */ | |||
| bool waitForThreadToExit (const int timeOutMilliseconds) const throw(); | |||
| /** Changes the thread's priority. | |||
| @param priority the new priority, in the range 0 (lowest) to 10 (highest). A priority | |||
| of 5 is normal. | |||
| */ | |||
| void setPriority (const int priority) throw(); | |||
| /** Changes the priority of the caller thread. | |||
| Similar to setPriority(), but this static method acts on the caller thread. | |||
| @see setPriority | |||
| */ | |||
| static void setCurrentThreadPriority (const int priority) throw(); | |||
| /** Sets the affinity mask for the thread. | |||
| This will only have an effect next time the thread is started - i.e. if the | |||
| thread is already running when called, it'll have no effect. | |||
| @see setCurrentThreadAffinityMask | |||
| */ | |||
| void setAffinityMask (const uint32 affinityMask) throw(); | |||
| /** Changes the affinity mask for the caller thread. | |||
| This will change the affinity mask for the thread that calls this static method. | |||
| @see setAffinityMask | |||
| */ | |||
| static void setCurrentThreadAffinityMask (const uint32 affinityMask) throw(); | |||
| // this can be called from any thread that needs to pause.. | |||
| static void JUCE_CALLTYPE sleep (int milliseconds) throw(); | |||
| /** Yields the calling thread's current time-slot. */ | |||
| static void JUCE_CALLTYPE yield() throw(); | |||
| /** Makes the thread wait for a notification. | |||
| This puts the thread to sleep until either the timeout period expires, or | |||
| another thread calls the notify() method to wake it up. | |||
| @returns true if the event has been signalled, false if the timeout expires. | |||
| */ | |||
| bool wait (const int timeOutMilliseconds) const throw(); | |||
| /** Wakes up the thread. | |||
| If the thread has called the wait() method, this will wake it up. | |||
| @see wait | |||
| */ | |||
| void notify() const throw(); | |||
| /** Returns an id that identifies the caller thread. | |||
| To find the ID of a particular thread object, use getThreadId(). | |||
| @returns a unique identifier that identifies the calling thread. | |||
| @see getThreadId | |||
| */ | |||
| static int64 getCurrentThreadId() throw(); | |||
| /** Finds the thread object that is currently running. | |||
| Note that the main UI thread (or other non-Juce threads) don't have a Thread | |||
| object associated with them, so this will return 0. | |||
| */ | |||
| static Thread* getCurrentThread() throw(); | |||
| /** Returns the ID of this thread. | |||
| That means the ID of this thread object - not of the thread that's calling the method. | |||
| This can change when the thread is started and stopped, and will be invalid if the | |||
| thread's not actually running. | |||
| @see getCurrentThreadId | |||
| */ | |||
| int64 getThreadId() const throw(); | |||
| /** Returns the name of the thread. | |||
| This is the name that gets set in the constructor. | |||
| */ | |||
| const String getThreadName() const throw() { return threadName_; } | |||
| /** Returns the number of currently-running threads. | |||
| @returns the number of Thread objects known to be currently running. | |||
| @see stopAllThreads | |||
| */ | |||
| static int getNumRunningThreads() throw(); | |||
| /** Tries to stop all currently-running threads. | |||
| This will attempt to stop all the threads known to be running at the moment. | |||
| */ | |||
| static void stopAllThreads (const int timeoutInMillisecs) throw(); | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| const String threadName_; | |||
| void* volatile threadHandle_; | |||
| CriticalSection startStopLock; | |||
| WaitableEvent startSuspensionEvent_, defaultEvent_; | |||
| int threadPriority_; | |||
| int64 threadId_; | |||
| uint32 affinityMask_; | |||
| bool volatile threadShouldExit_; | |||
| friend void JUCE_API juce_threadEntryPoint (void*); | |||
| static void threadEntryPoint (Thread* thread) throw(); | |||
| Thread (const Thread&); | |||
| const Thread& operator= (const Thread&); | |||
| }; | |||
| #endif // __JUCE_THREAD_JUCEHEADER__ | |||
| /********* End of inlined file: juce_Thread.h *********/ | |||
| #endif | |||
| #ifndef __JUCE_THREADPOOL_JUCEHEADER__ | |||
| @@ -37301,7 +37306,6 @@ private: | |||
| #ifndef __JUCE_MESSAGEMANAGER_JUCEHEADER__ | |||
| #define __JUCE_MESSAGEMANAGER_JUCEHEADER__ | |||
| class Thread; | |||
| class Component; | |||
| class MessageManagerLock; | |||
| @@ -37365,14 +37369,14 @@ public: | |||
| (Best to ignore this method unless you really know what you're doing..) | |||
| @see getCurrentMessageThread | |||
| */ | |||
| void setCurrentMessageThread (const int64 threadId) throw(); | |||
| void setCurrentMessageThread (const Thread::ThreadID threadId) throw(); | |||
| /** Returns the ID of the current message thread, as set by setCurrentMessageThread(). | |||
| (Best to ignore this method unless you really know what you're doing..) | |||
| @see setCurrentMessageThread | |||
| */ | |||
| int64 getCurrentMessageThread() const throw() { return messageThreadId; } | |||
| Thread::ThreadID getCurrentMessageThread() const throw() { return messageThreadId; } | |||
| /** Returns true if the caller thread has currenltly got the message manager locked. | |||
| @@ -37424,7 +37428,7 @@ private: | |||
| friend class JUCEApplication; | |||
| bool quitMessagePosted, quitMessageReceived; | |||
| int64 messageThreadId; | |||
| Thread::ThreadID messageThreadId; | |||
| VoidArray modalComponents; | |||
| static void* exitModalLoopCallback (void*); | |||
| @@ -37436,7 +37440,7 @@ private: | |||
| friend class MessageManagerLock; | |||
| CriticalSection messageDispatchLock; | |||
| int64 currentLockingThreadId; | |||
| Thread::ThreadID currentLockingThreadId; | |||
| MessageManager (const MessageManager&); | |||
| const MessageManager& operator= (const MessageManager&); | |||
| @@ -37539,7 +37543,7 @@ public: | |||
| bool lockWasGained() const throw() { return locked; } | |||
| private: | |||
| int64 lastLockingThreadId; | |||
| Thread::ThreadID lastLockingThreadId; | |||
| bool locked; | |||
| }; | |||
| @@ -315,7 +315,8 @@ private: | |||
| const int trackNum; | |||
| double trackUnitsPerFrame; | |||
| int samplesPerFrame; | |||
| int lastSampleRead, lastThreadId; | |||
| int lastSampleRead; | |||
| Thread::ThreadID lastThreadId; | |||
| MovieAudioExtractionRef extractor; | |||
| AudioStreamBasicDescription inputStreamDesc; | |||
| AudioBufferList* bufferList; | |||
| @@ -177,7 +177,7 @@ bool MessageManager::isThisTheMessageThread() const throw() | |||
| return Thread::getCurrentThreadId() == messageThreadId; | |||
| } | |||
| void MessageManager::setCurrentMessageThread (const int64 threadId) throw() | |||
| void MessageManager::setCurrentMessageThread (const Thread::ThreadID threadId) throw() | |||
| { | |||
| messageThreadId = threadId; | |||
| } | |||
| @@ -35,8 +35,8 @@ | |||
| #include "../application/juce_DeletedAtShutdown.h" | |||
| #include "../../juce_core/containers/juce_SortedSet.h" | |||
| #include "../../juce_core/containers/juce_VoidArray.h" | |||
| #include "../../juce_core/threads/juce_Thread.h" | |||
| #include "juce_ActionListenerList.h" | |||
| class Thread; | |||
| class Component; | |||
| class MessageManagerLock; | |||
| @@ -107,14 +107,14 @@ public: | |||
| (Best to ignore this method unless you really know what you're doing..) | |||
| @see getCurrentMessageThread | |||
| */ | |||
| void setCurrentMessageThread (const int64 threadId) throw(); | |||
| void setCurrentMessageThread (const Thread::ThreadID threadId) throw(); | |||
| /** Returns the ID of the current message thread, as set by setCurrentMessageThread(). | |||
| (Best to ignore this method unless you really know what you're doing..) | |||
| @see setCurrentMessageThread | |||
| */ | |||
| int64 getCurrentMessageThread() const throw() { return messageThreadId; } | |||
| Thread::ThreadID getCurrentMessageThread() const throw() { return messageThreadId; } | |||
| /** Returns true if the caller thread has currenltly got the message manager locked. | |||
| @@ -169,7 +169,7 @@ private: | |||
| friend class JUCEApplication; | |||
| bool quitMessagePosted, quitMessageReceived; | |||
| int64 messageThreadId; | |||
| Thread::ThreadID messageThreadId; | |||
| VoidArray modalComponents; | |||
| static void* exitModalLoopCallback (void*); | |||
| @@ -181,7 +181,7 @@ private: | |||
| friend class MessageManagerLock; | |||
| CriticalSection messageDispatchLock; | |||
| int64 currentLockingThreadId; | |||
| Thread::ThreadID currentLockingThreadId; | |||
| MessageManager (const MessageManager&); | |||
| const MessageManager& operator= (const MessageManager&); | |||
| @@ -289,7 +289,7 @@ public: | |||
| private: | |||
| int64 lastLockingThreadId; | |||
| Thread::ThreadID lastLockingThreadId; | |||
| bool locked; | |||
| }; | |||
| @@ -56,7 +56,7 @@ ReadWriteLock::~ReadWriteLock() throw() | |||
| //============================================================================== | |||
| void ReadWriteLock::enterRead() const throw() | |||
| { | |||
| const int64 threadId = Thread::getCurrentThreadId(); | |||
| const Thread::ThreadID threadId = Thread::getCurrentThreadId(); | |||
| const ScopedLock sl (accessLock); | |||
| for (;;) | |||
| @@ -74,12 +74,12 @@ void ReadWriteLock::enterRead() const throw() | |||
| { | |||
| if (i < readerThreads.size()) | |||
| { | |||
| readerThreads.set (i + 1, readerThreads.getUnchecked (i + 1) + 1); | |||
| readerThreads.set (i + 1, (Thread::ThreadID) (1 + (pointer_sized_int) readerThreads.getUnchecked (i + 1))); | |||
| } | |||
| else | |||
| { | |||
| readerThreads.add (threadId); | |||
| readerThreads.add (1); | |||
| readerThreads.add ((Thread::ThreadID) 1); | |||
| } | |||
| return; | |||
| @@ -92,14 +92,14 @@ void ReadWriteLock::enterRead() const throw() | |||
| void ReadWriteLock::exitRead() const throw() | |||
| { | |||
| const int64 threadId = Thread::getCurrentThreadId(); | |||
| const Thread::ThreadID threadId = Thread::getCurrentThreadId(); | |||
| const ScopedLock sl (accessLock); | |||
| for (int i = 0; i < readerThreads.size(); i += 2) | |||
| { | |||
| if (readerThreads.getUnchecked(i) == threadId) | |||
| { | |||
| const int newCount = ((int) readerThreads.getUnchecked (i + 1)) - 1; | |||
| const int newCount = ((int) (Thread::ThreadID) readerThreads.getUnchecked (i + 1)) - 1; | |||
| if (newCount == 0) | |||
| { | |||
| @@ -108,7 +108,7 @@ void ReadWriteLock::exitRead() const throw() | |||
| } | |||
| else | |||
| { | |||
| readerThreads.set (i + 1, newCount); | |||
| readerThreads.set (i + 1, (Thread::ThreadID) (pointer_sized_int) newCount); | |||
| } | |||
| return; | |||
| @@ -121,7 +121,7 @@ void ReadWriteLock::exitRead() const throw() | |||
| //============================================================================== | |||
| void ReadWriteLock::enterWrite() const throw() | |||
| { | |||
| const int64 threadId = Thread::getCurrentThreadId(); | |||
| const Thread::ThreadID threadId = Thread::getCurrentThreadId(); | |||
| const ScopedLock sl (accessLock); | |||
| for (;;) | |||
| @@ -146,7 +146,7 @@ void ReadWriteLock::enterWrite() const throw() | |||
| bool ReadWriteLock::tryEnterWrite() const throw() | |||
| { | |||
| const int64 threadId = Thread::getCurrentThreadId(); | |||
| const Thread::ThreadID threadId = Thread::getCurrentThreadId(); | |||
| const ScopedLock sl (accessLock); | |||
| if (readerThreads.size() + numWriters == 0 | |||
| @@ -34,6 +34,7 @@ | |||
| #include "juce_CriticalSection.h" | |||
| #include "juce_WaitableEvent.h" | |||
| #include "juce_Thread.h" | |||
| #include "../containers/juce_Array.h" | |||
| @@ -134,8 +135,8 @@ private: | |||
| CriticalSection accessLock; | |||
| WaitableEvent waitEvent; | |||
| mutable int numWaitingWriters, numWriters; | |||
| mutable int64 writerThreadId; | |||
| mutable Array <int64> readerThreads; | |||
| mutable Thread::ThreadID writerThreadId; | |||
| mutable Array <Thread::ThreadID> readerThreads; | |||
| ReadWriteLock (const ReadWriteLock&); | |||
| const ReadWriteLock& operator= (const ReadWriteLock&); | |||
| @@ -225,7 +225,7 @@ void Thread::setAffinityMask (const uint32 affinityMask) throw() | |||
| affinityMask_ = affinityMask; | |||
| } | |||
| int64 Thread::getThreadId() const throw() | |||
| Thread::ThreadID Thread::getThreadId() const throw() | |||
| { | |||
| return threadId_; | |||
| } | |||
| @@ -249,7 +249,7 @@ int Thread::getNumRunningThreads() throw() | |||
| Thread* Thread::getCurrentThread() throw() | |||
| { | |||
| const int64 thisId = getCurrentThreadId(); | |||
| const ThreadID thisId = getCurrentThreadId(); | |||
| Thread* result = 0; | |||
| runningThreadsLock.enter(); | |||
| @@ -216,6 +216,11 @@ public: | |||
| void notify() const throw(); | |||
| //============================================================================== | |||
| /** A value type used for thread IDs. | |||
| @see getCurrentThreadId(), getThreadId() | |||
| */ | |||
| typedef void* ThreadID; | |||
| /** Returns an id that identifies the caller thread. | |||
| To find the ID of a particular thread object, use getThreadId(). | |||
| @@ -223,7 +228,7 @@ public: | |||
| @returns a unique identifier that identifies the calling thread. | |||
| @see getThreadId | |||
| */ | |||
| static int64 getCurrentThreadId() throw(); | |||
| static ThreadID getCurrentThreadId() throw(); | |||
| /** Finds the thread object that is currently running. | |||
| @@ -241,7 +246,7 @@ public: | |||
| @see getCurrentThreadId | |||
| */ | |||
| int64 getThreadId() const throw(); | |||
| ThreadID getThreadId() const throw(); | |||
| /** Returns the name of the thread. | |||
| @@ -274,7 +279,7 @@ private: | |||
| WaitableEvent startSuspensionEvent_, defaultEvent_; | |||
| int threadPriority_; | |||
| int64 threadId_; | |||
| ThreadID threadId_; | |||
| uint32 affinityMask_; | |||
| bool volatile threadShouldExit_; | |||