| @@ -173,16 +173,26 @@ private: | |||
| testSound.clear(); | |||
| float* s = testSound.getSampleData (0, 0); | |||
| IntegerElementComparator<int> comp; | |||
| Random rand (0); | |||
| rand.setSeedRandomly(); | |||
| for (int i = 0; i < length; ++i) | |||
| s[i] = (rand.nextFloat() - rand.nextFloat() + rand.nextFloat() - rand.nextFloat()) * 0.06f; | |||
| spikes.clear(); | |||
| for (int i = 0; i < 50; ++i) | |||
| int spikePos = 0; | |||
| int spikeDelta = 50; | |||
| while (spikePos < length) | |||
| { | |||
| const int spikePos = Random::getSystemRandom().nextInt (length - 20) + 10; | |||
| spikes.addSorted (comp, spikePos); | |||
| spikes.add (spikePos); | |||
| s [spikePos] = 0.99f; | |||
| s [spikePos + 1] = -0.99f; | |||
| spikePos += spikeDelta; | |||
| spikeDelta += spikeDelta / 6 + rand.nextInt (5); | |||
| } | |||
| } | |||
| @@ -15561,17 +15561,17 @@ ThreadPoolJob::~ThreadPoolJob() | |||
| jassert (pool == 0 || ! pool->contains (this)); | |||
| } | |||
| const String ThreadPoolJob::getJobName() const | |||
| const String ThreadPoolJob::getJobName() const throw() | |||
| { | |||
| return jobName; | |||
| } | |||
| void ThreadPoolJob::setJobName (const String& newName) | |||
| void ThreadPoolJob::setJobName (const String& newName) throw() | |||
| { | |||
| jobName = newName; | |||
| } | |||
| void ThreadPoolJob::signalJobShouldExit() | |||
| void ThreadPoolJob::signalJobShouldExit() throw() | |||
| { | |||
| shouldStop = true; | |||
| } | |||
| @@ -15680,7 +15680,7 @@ void ThreadPool::addJob (ThreadPoolJob* const job) | |||
| } | |||
| if (! startedOne) | |||
| Thread::sleep (5); | |||
| Thread::sleep (2); | |||
| } | |||
| } | |||
| @@ -15696,7 +15696,7 @@ int ThreadPool::getNumJobs() const throw() | |||
| return jobs.size(); | |||
| } | |||
| ThreadPoolJob* ThreadPool::getJob (const int index) const | |||
| ThreadPoolJob* ThreadPool::getJob (const int index) const throw() | |||
| { | |||
| const ScopedLock sl (lock); | |||
| return (ThreadPoolJob*) jobs [index]; | |||
| @@ -15705,14 +15705,12 @@ ThreadPoolJob* ThreadPool::getJob (const int index) const | |||
| bool ThreadPool::contains (const ThreadPoolJob* const job) const throw() | |||
| { | |||
| const ScopedLock sl (lock); | |||
| return jobs.contains ((void*) job); | |||
| } | |||
| bool ThreadPool::isJobRunning (const ThreadPoolJob* const job) const | |||
| { | |||
| const ScopedLock sl (lock); | |||
| return jobs.contains ((void*) job) && job->isActive; | |||
| } | |||
| @@ -15728,7 +15726,7 @@ bool ThreadPool::waitForJobToFinish (const ThreadPoolJob* const job, | |||
| if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + timeOutMs) | |||
| return false; | |||
| Thread::sleep (2); | |||
| jobFinishedSignal.wait (2); | |||
| } | |||
| } | |||
| @@ -15799,13 +15797,13 @@ bool ThreadPool::removeAllJobs (const bool interruptRunningJobs, | |||
| if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + timeOutMs) | |||
| return false; | |||
| Thread::sleep (2); | |||
| jobFinishedSignal.wait (2); | |||
| } | |||
| return true; | |||
| } | |||
| const StringArray ThreadPool::getNamesOfAllJobs (const bool onlyReturnActiveJobs) const | |||
| const StringArray ThreadPool::getNamesOfAllJobs (const bool onlyReturnActiveJobs) const throw() | |||
| { | |||
| StringArray s; | |||
| const ScopedLock sl (lock); | |||
| @@ -15876,6 +15874,8 @@ bool ThreadPool::runNextJob() | |||
| if (result == ThreadPoolJob::jobHasFinishedAndShouldBeDeleted) | |||
| delete job; | |||
| jobFinishedSignal.signal(); | |||
| } | |||
| else | |||
| { | |||
| @@ -15900,15 +15900,11 @@ bool ThreadPool::runNextJob() | |||
| if (threadStopTimeout > 0 | |||
| && Time::getApproximateMillisecondCounter() > lastJobEndTime + threadStopTimeout) | |||
| { | |||
| lock.enter(); | |||
| const ScopedLock sl (lock); | |||
| if (jobs.size() == 0) | |||
| { | |||
| for (int i = numThreads; --i >= 0;) | |||
| threads[i]->signalThreadShouldExit(); | |||
| } | |||
| lock.exit(); | |||
| } | |||
| else | |||
| { | |||
| @@ -50006,7 +50002,7 @@ void TextEditor::focusGained (FocusChangeType) | |||
| textHolder->startTimer (flashSpeedIntervalMs); | |||
| ComponentPeer* const peer = getPeer(); | |||
| if (peer != 0) | |||
| if (peer != 0 && ! isReadOnly()) | |||
| peer->textInputRequired (getScreenX() - peer->getScreenX(), | |||
| getScreenY() - peer->getScreenY()); | |||
| } | |||
| @@ -73111,8 +73107,9 @@ DocumentWindow::~DocumentWindow() | |||
| void DocumentWindow::repaintTitleBar() | |||
| { | |||
| const int border = getBorderSize(); | |||
| repaint (border, border, getWidth() - border * 2, getTitleBarHeight()); | |||
| const Rectangle titleBarArea (getTitleBarArea()); | |||
| repaint (titleBarArea.getX(), titleBarArea.getY(), | |||
| titleBarArea.getWidth(), titleBarArea.getHeight()); | |||
| } | |||
| void DocumentWindow::setName (const String& newName) | |||
| @@ -73211,19 +73208,24 @@ void DocumentWindow::paint (Graphics& g) | |||
| { | |||
| ResizableWindow::paint (g); | |||
| if (resizableBorder == 0 && getBorderSize() == 1) | |||
| if (resizableBorder == 0) | |||
| { | |||
| g.setColour (getBackgroundColour().overlaidWith (Colour (0x80000000))); | |||
| g.drawRect (0, 0, getWidth(), getHeight()); | |||
| } | |||
| const int border = getBorderSize(); | |||
| const BorderSize border (getBorderThickness()); | |||
| g.fillRect (0, 0, getWidth(), border.getTop()); | |||
| g.fillRect (0, border.getTop(), border.getLeft(), getHeight() - border.getTopAndBottom()); | |||
| g.fillRect (getWidth() - border.getRight(), border.getTop(), border.getRight(), getHeight() - border.getTopAndBottom()); | |||
| g.fillRect (0, getHeight() - border.getBottom(), getWidth(), border.getBottom()); | |||
| } | |||
| g.setOrigin (border, border); | |||
| g.reduceClipRegion (0, 0, getWidth() - border * 2, getTitleBarHeight()); | |||
| const Rectangle titleBarArea (getTitleBarArea()); | |||
| g.setOrigin (titleBarArea.getX(), titleBarArea.getY()); | |||
| g.reduceClipRegion (0, 0, titleBarArea.getWidth(), titleBarArea.getHeight()); | |||
| int titleSpaceX1 = 6; | |||
| int titleSpaceX2 = getWidth() - 6; | |||
| int titleSpaceX2 = titleBarArea.getWidth() - 6; | |||
| for (int i = 0; i < 3; ++i) | |||
| { | |||
| @@ -73236,12 +73238,13 @@ void DocumentWindow::paint (Graphics& g) | |||
| } | |||
| } | |||
| getLookAndFeel() | |||
| .drawDocumentWindowTitleBar (*this, g, | |||
| getWidth() - border * 2, | |||
| getTitleBarHeight(), | |||
| titleSpaceX1, jmax (1, titleSpaceX2 - titleSpaceX1), | |||
| titleBarIcon, ! drawTitleTextCentred); | |||
| getLookAndFeel().drawDocumentWindowTitleBar (*this, g, | |||
| titleBarArea.getWidth(), | |||
| titleBarArea.getHeight(), | |||
| titleSpaceX1, | |||
| jmax (1, titleSpaceX2 - titleSpaceX1), | |||
| titleBarIcon, | |||
| ! drawTitleTextCentred); | |||
| } | |||
| void DocumentWindow::resized() | |||
| @@ -73251,19 +73254,51 @@ void DocumentWindow::resized() | |||
| if (titleBarButtons[1] != 0) | |||
| titleBarButtons[1]->setToggleState (isFullScreen(), false); | |||
| const int border = getBorderSize(); | |||
| const Rectangle titleBarArea (getTitleBarArea()); | |||
| getLookAndFeel() | |||
| .positionDocumentWindowButtons (*this, | |||
| border, border, | |||
| getWidth() - border * 2, getTitleBarHeight(), | |||
| titleBarArea.getX(), titleBarArea.getY(), | |||
| titleBarArea.getWidth(), titleBarArea.getHeight(), | |||
| titleBarButtons[0], | |||
| titleBarButtons[1], | |||
| titleBarButtons[2], | |||
| positionTitleBarButtonsOnLeft); | |||
| if (menuBar != 0) | |||
| menuBar->setBounds (border, border + getTitleBarHeight(), | |||
| getWidth() - border * 2, menuBarHeight); | |||
| menuBar->setBounds (titleBarArea.getX(), titleBarArea.getBottom(), | |||
| titleBarArea.getWidth(), menuBarHeight); | |||
| } | |||
| const BorderSize DocumentWindow::getBorderThickness() | |||
| { | |||
| return BorderSize ((isFullScreen() || isUsingNativeTitleBar()) | |||
| ? 0 : (resizableBorder != 0 ? 4 : 1)); | |||
| } | |||
| const BorderSize DocumentWindow::getContentComponentBorder() | |||
| { | |||
| BorderSize border (getBorderThickness()); | |||
| border.setTop (border.getTop() | |||
| + (isUsingNativeTitleBar() ? 0 : titleBarHeight) | |||
| + (menuBar != 0 ? menuBarHeight : 0)); | |||
| return border; | |||
| } | |||
| int DocumentWindow::getTitleBarHeight() const | |||
| { | |||
| return isUsingNativeTitleBar() ? 0 : jmin (titleBarHeight, getHeight() - 4); | |||
| } | |||
| const Rectangle DocumentWindow::getTitleBarArea() | |||
| { | |||
| const BorderSize border (getBorderThickness()); | |||
| return Rectangle (border.getLeft(), border.getTop(), | |||
| getWidth() - border.getLeftAndRight(), | |||
| getTitleBarHeight()); | |||
| } | |||
| Button* DocumentWindow::getCloseButton() const throw() | |||
| @@ -73359,29 +73394,9 @@ void DocumentWindow::activeWindowStatusChanged() | |||
| menuBar->setEnabled (isActiveWindow()); | |||
| } | |||
| const BorderSize DocumentWindow::getBorderThickness() | |||
| { | |||
| return BorderSize (getBorderSize()); | |||
| } | |||
| const BorderSize DocumentWindow::getContentComponentBorder() | |||
| { | |||
| const int size = getBorderSize(); | |||
| return BorderSize (size | |||
| + (isUsingNativeTitleBar() ? 0 : titleBarHeight) | |||
| + (menuBar != 0 ? menuBarHeight : 0), | |||
| size, size, size); | |||
| } | |||
| void DocumentWindow::mouseDoubleClick (const MouseEvent& e) | |||
| { | |||
| const int border = getBorderSize(); | |||
| if (e.x >= border | |||
| && e.y >= border | |||
| && e.x < getWidth() - border | |||
| && e.y < border + getTitleBarHeight() | |||
| if (getTitleBarArea().contains (e.x, e.y) | |||
| && getMaximiseButton() != 0) | |||
| { | |||
| getMaximiseButton()->triggerClick(); | |||
| @@ -73393,16 +73408,6 @@ void DocumentWindow::userTriedToCloseWindow() | |||
| closeButtonPressed(); | |||
| } | |||
| int DocumentWindow::getTitleBarHeight() const | |||
| { | |||
| return isUsingNativeTitleBar() ? 0 : jmin (titleBarHeight, getHeight() - 4); | |||
| } | |||
| int DocumentWindow::getBorderSize() const | |||
| { | |||
| return (isFullScreen() || isUsingNativeTitleBar()) ? 0 : (resizableBorder != 0 ? 4 : 1); | |||
| } | |||
| DocumentWindow::ButtonListenerProxy::ButtonListenerProxy() | |||
| { | |||
| } | |||
| @@ -247254,6 +247259,9 @@ public: | |||
| inputDeviceNames.insert (index, name); | |||
| } | |||
| } | |||
| inputDeviceNames.appendNumbersToDuplicates (false, false); | |||
| outputDeviceNames.appendNumbersToDuplicates (false, false); | |||
| } | |||
| const StringArray getDeviceNames (const bool wantInputNames) const | |||
| @@ -14960,12 +14960,12 @@ public: | |||
| /** Returns the name of this job. | |||
| @see setJobName | |||
| */ | |||
| const String getJobName() const; | |||
| const String getJobName() const throw(); | |||
| /** Changes the job's name. | |||
| @see getJobName | |||
| */ | |||
| void setJobName (const String& newName); | |||
| void setJobName (const String& newName) throw(); | |||
| /** These are the values that can be returned by the runJob() method. | |||
| */ | |||
| @@ -15014,7 +15014,7 @@ public: | |||
| @see shouldExit() | |||
| */ | |||
| void signalJobShouldExit(); | |||
| void signalJobShouldExit() throw(); | |||
| juce_UseDebuggingNewOperator | |||
| @@ -15120,7 +15120,7 @@ public: | |||
| Note that this can be a very volatile list as jobs might be continuously getting shifted | |||
| around in the list, and this method may return 0 if the index is currently out-of-range. | |||
| */ | |||
| ThreadPoolJob* getJob (const int index) const; | |||
| ThreadPoolJob* getJob (const int index) const throw(); | |||
| /** Returns true if the given job is currently queued or running. | |||
| @@ -15147,7 +15147,7 @@ public: | |||
| If onlyReturnActiveJobs is true, only the ones currently running are returned. | |||
| */ | |||
| const StringArray getNamesOfAllJobs (const bool onlyReturnActiveJobs) const; | |||
| const StringArray getNamesOfAllJobs (const bool onlyReturnActiveJobs) const throw(); | |||
| /** Changes the priority of all the threads. | |||
| @@ -15166,6 +15166,7 @@ private: | |||
| CriticalSection lock; | |||
| uint32 lastJobEndTime; | |||
| WaitableEvent jobFinishedSignal; | |||
| friend class ThreadPoolThread; | |||
| bool runNextJob(); | |||
| @@ -49122,6 +49123,8 @@ public: | |||
| int getDesktopWindowStyleFlags() const; | |||
| /** @internal */ | |||
| void parentHierarchyChanged(); | |||
| /** @internal */ | |||
| const Rectangle getTitleBarArea(); | |||
| juce_UseDebuggingNewOperator | |||
| @@ -49143,7 +49146,6 @@ private: | |||
| } buttonListener; | |||
| int getBorderSize() const; | |||
| void repaintTitleBar(); | |||
| DocumentWindow (const DocumentWindow&); | |||
| @@ -51903,6 +51905,10 @@ public: | |||
| */ | |||
| void setStatusMessage (const String& newStatusMessage); | |||
| /** Returns the AlertWindow that is being used. | |||
| */ | |||
| AlertWindow* getAlertWindow() const throw() { return alertWindow; } | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| @@ -2169,7 +2169,7 @@ void TextEditor::focusGained (FocusChangeType) | |||
| textHolder->startTimer (flashSpeedIntervalMs); | |||
| ComponentPeer* const peer = getPeer(); | |||
| if (peer != 0) | |||
| if (peer != 0 && ! isReadOnly()) | |||
| peer->textInputRequired (getScreenX() - peer->getScreenX(), | |||
| getScreenY() - peer->getScreenY()); | |||
| } | |||
| @@ -71,8 +71,9 @@ DocumentWindow::~DocumentWindow() | |||
| //============================================================================== | |||
| void DocumentWindow::repaintTitleBar() | |||
| { | |||
| const int border = getBorderSize(); | |||
| repaint (border, border, getWidth() - border * 2, getTitleBarHeight()); | |||
| const Rectangle titleBarArea (getTitleBarArea()); | |||
| repaint (titleBarArea.getX(), titleBarArea.getY(), | |||
| titleBarArea.getWidth(), titleBarArea.getHeight()); | |||
| } | |||
| void DocumentWindow::setName (const String& newName) | |||
| @@ -174,19 +175,24 @@ void DocumentWindow::paint (Graphics& g) | |||
| { | |||
| ResizableWindow::paint (g); | |||
| if (resizableBorder == 0 && getBorderSize() == 1) | |||
| if (resizableBorder == 0) | |||
| { | |||
| g.setColour (getBackgroundColour().overlaidWith (Colour (0x80000000))); | |||
| g.drawRect (0, 0, getWidth(), getHeight()); | |||
| const BorderSize border (getBorderThickness()); | |||
| g.fillRect (0, 0, getWidth(), border.getTop()); | |||
| g.fillRect (0, border.getTop(), border.getLeft(), getHeight() - border.getTopAndBottom()); | |||
| g.fillRect (getWidth() - border.getRight(), border.getTop(), border.getRight(), getHeight() - border.getTopAndBottom()); | |||
| g.fillRect (0, getHeight() - border.getBottom(), getWidth(), border.getBottom()); | |||
| } | |||
| const int border = getBorderSize(); | |||
| g.setOrigin (border, border); | |||
| g.reduceClipRegion (0, 0, getWidth() - border * 2, getTitleBarHeight()); | |||
| const Rectangle titleBarArea (getTitleBarArea()); | |||
| g.setOrigin (titleBarArea.getX(), titleBarArea.getY()); | |||
| g.reduceClipRegion (0, 0, titleBarArea.getWidth(), titleBarArea.getHeight()); | |||
| int titleSpaceX1 = 6; | |||
| int titleSpaceX2 = getWidth() - 6; | |||
| int titleSpaceX2 = titleBarArea.getWidth() - 6; | |||
| for (int i = 0; i < 3; ++i) | |||
| { | |||
| @@ -199,12 +205,13 @@ void DocumentWindow::paint (Graphics& g) | |||
| } | |||
| } | |||
| getLookAndFeel() | |||
| .drawDocumentWindowTitleBar (*this, g, | |||
| getWidth() - border * 2, | |||
| getTitleBarHeight(), | |||
| titleSpaceX1, jmax (1, titleSpaceX2 - titleSpaceX1), | |||
| titleBarIcon, ! drawTitleTextCentred); | |||
| getLookAndFeel().drawDocumentWindowTitleBar (*this, g, | |||
| titleBarArea.getWidth(), | |||
| titleBarArea.getHeight(), | |||
| titleSpaceX1, | |||
| jmax (1, titleSpaceX2 - titleSpaceX1), | |||
| titleBarIcon, | |||
| ! drawTitleTextCentred); | |||
| } | |||
| void DocumentWindow::resized() | |||
| @@ -214,19 +221,51 @@ void DocumentWindow::resized() | |||
| if (titleBarButtons[1] != 0) | |||
| titleBarButtons[1]->setToggleState (isFullScreen(), false); | |||
| const int border = getBorderSize(); | |||
| const Rectangle titleBarArea (getTitleBarArea()); | |||
| getLookAndFeel() | |||
| .positionDocumentWindowButtons (*this, | |||
| border, border, | |||
| getWidth() - border * 2, getTitleBarHeight(), | |||
| titleBarArea.getX(), titleBarArea.getY(), | |||
| titleBarArea.getWidth(), titleBarArea.getHeight(), | |||
| titleBarButtons[0], | |||
| titleBarButtons[1], | |||
| titleBarButtons[2], | |||
| positionTitleBarButtonsOnLeft); | |||
| if (menuBar != 0) | |||
| menuBar->setBounds (border, border + getTitleBarHeight(), | |||
| getWidth() - border * 2, menuBarHeight); | |||
| menuBar->setBounds (titleBarArea.getX(), titleBarArea.getBottom(), | |||
| titleBarArea.getWidth(), menuBarHeight); | |||
| } | |||
| const BorderSize DocumentWindow::getBorderThickness() | |||
| { | |||
| return BorderSize ((isFullScreen() || isUsingNativeTitleBar()) | |||
| ? 0 : (resizableBorder != 0 ? 4 : 1)); | |||
| } | |||
| const BorderSize DocumentWindow::getContentComponentBorder() | |||
| { | |||
| BorderSize border (getBorderThickness()); | |||
| border.setTop (border.getTop() | |||
| + (isUsingNativeTitleBar() ? 0 : titleBarHeight) | |||
| + (menuBar != 0 ? menuBarHeight : 0)); | |||
| return border; | |||
| } | |||
| int DocumentWindow::getTitleBarHeight() const | |||
| { | |||
| return isUsingNativeTitleBar() ? 0 : jmin (titleBarHeight, getHeight() - 4); | |||
| } | |||
| const Rectangle DocumentWindow::getTitleBarArea() | |||
| { | |||
| const BorderSize border (getBorderThickness()); | |||
| return Rectangle (border.getLeft(), border.getTop(), | |||
| getWidth() - border.getLeftAndRight(), | |||
| getTitleBarHeight()); | |||
| } | |||
| Button* DocumentWindow::getCloseButton() const throw() | |||
| @@ -322,29 +361,9 @@ void DocumentWindow::activeWindowStatusChanged() | |||
| menuBar->setEnabled (isActiveWindow()); | |||
| } | |||
| const BorderSize DocumentWindow::getBorderThickness() | |||
| { | |||
| return BorderSize (getBorderSize()); | |||
| } | |||
| const BorderSize DocumentWindow::getContentComponentBorder() | |||
| { | |||
| const int size = getBorderSize(); | |||
| return BorderSize (size | |||
| + (isUsingNativeTitleBar() ? 0 : titleBarHeight) | |||
| + (menuBar != 0 ? menuBarHeight : 0), | |||
| size, size, size); | |||
| } | |||
| void DocumentWindow::mouseDoubleClick (const MouseEvent& e) | |||
| { | |||
| const int border = getBorderSize(); | |||
| if (e.x >= border | |||
| && e.y >= border | |||
| && e.x < getWidth() - border | |||
| && e.y < border + getTitleBarHeight() | |||
| if (getTitleBarArea().contains (e.x, e.y) | |||
| && getMaximiseButton() != 0) | |||
| { | |||
| getMaximiseButton()->triggerClick(); | |||
| @@ -356,17 +375,6 @@ void DocumentWindow::userTriedToCloseWindow() | |||
| closeButtonPressed(); | |||
| } | |||
| //============================================================================== | |||
| int DocumentWindow::getTitleBarHeight() const | |||
| { | |||
| return isUsingNativeTitleBar() ? 0 : jmin (titleBarHeight, getHeight() - 4); | |||
| } | |||
| int DocumentWindow::getBorderSize() const | |||
| { | |||
| return (isFullScreen() || isUsingNativeTitleBar()) ? 0 : (resizableBorder != 0 ? 4 : 1); | |||
| } | |||
| //============================================================================== | |||
| DocumentWindow::ButtonListenerProxy::ButtonListenerProxy() | |||
| { | |||
| @@ -239,7 +239,8 @@ public: | |||
| int getDesktopWindowStyleFlags() const; | |||
| /** @internal */ | |||
| void parentHierarchyChanged(); | |||
| /** @internal */ | |||
| const Rectangle getTitleBarArea(); | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| @@ -262,7 +263,6 @@ private: | |||
| } buttonListener; | |||
| int getBorderSize() const; | |||
| void repaintTitleBar(); | |||
| DocumentWindow (const DocumentWindow&); | |||
| @@ -141,6 +141,9 @@ public: | |||
| */ | |||
| void setStatusMessage (const String& newStatusMessage); | |||
| /** Returns the AlertWindow that is being used. | |||
| */ | |||
| AlertWindow* getAlertWindow() const throw() { return alertWindow; } | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| @@ -991,6 +991,9 @@ public: | |||
| inputDeviceNames.insert (index, name); | |||
| } | |||
| } | |||
| inputDeviceNames.appendNumbersToDuplicates (false, false); | |||
| outputDeviceNames.appendNumbersToDuplicates (false, false); | |||
| } | |||
| const StringArray getDeviceNames (const bool wantInputNames) const | |||
| @@ -49,17 +49,17 @@ ThreadPoolJob::~ThreadPoolJob() | |||
| jassert (pool == 0 || ! pool->contains (this)); | |||
| } | |||
| const String ThreadPoolJob::getJobName() const | |||
| const String ThreadPoolJob::getJobName() const throw() | |||
| { | |||
| return jobName; | |||
| } | |||
| void ThreadPoolJob::setJobName (const String& newName) | |||
| void ThreadPoolJob::setJobName (const String& newName) throw() | |||
| { | |||
| jobName = newName; | |||
| } | |||
| void ThreadPoolJob::signalJobShouldExit() | |||
| void ThreadPoolJob::signalJobShouldExit() throw() | |||
| { | |||
| shouldStop = true; | |||
| } | |||
| @@ -171,7 +171,7 @@ void ThreadPool::addJob (ThreadPoolJob* const job) | |||
| } | |||
| if (! startedOne) | |||
| Thread::sleep (5); | |||
| Thread::sleep (2); | |||
| } | |||
| } | |||
| @@ -187,7 +187,7 @@ int ThreadPool::getNumJobs() const throw() | |||
| return jobs.size(); | |||
| } | |||
| ThreadPoolJob* ThreadPool::getJob (const int index) const | |||
| ThreadPoolJob* ThreadPool::getJob (const int index) const throw() | |||
| { | |||
| const ScopedLock sl (lock); | |||
| return (ThreadPoolJob*) jobs [index]; | |||
| @@ -196,14 +196,12 @@ ThreadPoolJob* ThreadPool::getJob (const int index) const | |||
| bool ThreadPool::contains (const ThreadPoolJob* const job) const throw() | |||
| { | |||
| const ScopedLock sl (lock); | |||
| return jobs.contains ((void*) job); | |||
| } | |||
| bool ThreadPool::isJobRunning (const ThreadPoolJob* const job) const | |||
| { | |||
| const ScopedLock sl (lock); | |||
| return jobs.contains ((void*) job) && job->isActive; | |||
| } | |||
| @@ -219,7 +217,7 @@ bool ThreadPool::waitForJobToFinish (const ThreadPoolJob* const job, | |||
| if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + timeOutMs) | |||
| return false; | |||
| Thread::sleep (2); | |||
| jobFinishedSignal.wait (2); | |||
| } | |||
| } | |||
| @@ -290,13 +288,13 @@ bool ThreadPool::removeAllJobs (const bool interruptRunningJobs, | |||
| if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + timeOutMs) | |||
| return false; | |||
| Thread::sleep (2); | |||
| jobFinishedSignal.wait (2); | |||
| } | |||
| return true; | |||
| } | |||
| const StringArray ThreadPool::getNamesOfAllJobs (const bool onlyReturnActiveJobs) const | |||
| const StringArray ThreadPool::getNamesOfAllJobs (const bool onlyReturnActiveJobs) const throw() | |||
| { | |||
| StringArray s; | |||
| const ScopedLock sl (lock); | |||
| @@ -367,6 +365,8 @@ bool ThreadPool::runNextJob() | |||
| if (result == ThreadPoolJob::jobHasFinishedAndShouldBeDeleted) | |||
| delete job; | |||
| jobFinishedSignal.signal(); | |||
| } | |||
| else | |||
| { | |||
| @@ -391,15 +391,11 @@ bool ThreadPool::runNextJob() | |||
| if (threadStopTimeout > 0 | |||
| && Time::getApproximateMillisecondCounter() > lastJobEndTime + threadStopTimeout) | |||
| { | |||
| lock.enter(); | |||
| const ScopedLock sl (lock); | |||
| if (jobs.size() == 0) | |||
| { | |||
| for (int i = numThreads; --i >= 0;) | |||
| threads[i]->signalThreadShouldExit(); | |||
| } | |||
| lock.exit(); | |||
| } | |||
| else | |||
| { | |||
| @@ -65,12 +65,12 @@ public: | |||
| /** Returns the name of this job. | |||
| @see setJobName | |||
| */ | |||
| const String getJobName() const; | |||
| const String getJobName() const throw(); | |||
| /** Changes the job's name. | |||
| @see getJobName | |||
| */ | |||
| void setJobName (const String& newName); | |||
| void setJobName (const String& newName) throw(); | |||
| //============================================================================== | |||
| /** These are the values that can be returned by the runJob() method. | |||
| @@ -122,7 +122,7 @@ public: | |||
| @see shouldExit() | |||
| */ | |||
| void signalJobShouldExit(); | |||
| void signalJobShouldExit() throw(); | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| @@ -232,7 +232,7 @@ public: | |||
| Note that this can be a very volatile list as jobs might be continuously getting shifted | |||
| around in the list, and this method may return 0 if the index is currently out-of-range. | |||
| */ | |||
| ThreadPoolJob* getJob (const int index) const; | |||
| ThreadPoolJob* getJob (const int index) const throw(); | |||
| /** Returns true if the given job is currently queued or running. | |||
| @@ -259,7 +259,7 @@ public: | |||
| If onlyReturnActiveJobs is true, only the ones currently running are returned. | |||
| */ | |||
| const StringArray getNamesOfAllJobs (const bool onlyReturnActiveJobs) const; | |||
| const StringArray getNamesOfAllJobs (const bool onlyReturnActiveJobs) const throw(); | |||
| /** Changes the priority of all the threads. | |||
| @@ -280,6 +280,7 @@ private: | |||
| CriticalSection lock; | |||
| uint32 lastJobEndTime; | |||
| WaitableEvent jobFinishedSignal; | |||
| friend class ThreadPoolThread; | |||
| bool runNextJob(); | |||