diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj
index 9fe63f939..432b76eba 100644
--- a/Builds/VisualStudio2012/beast.vcxproj
+++ b/Builds/VisualStudio2012/beast.vcxproj
@@ -287,10 +287,7 @@
-
-
-
@@ -1102,24 +1099,12 @@
true
true
-
- true
- true
- true
- true
-
true
true
true
true
-
- true
- true
- true
- true
-
true
true
diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters
index a98e789c3..8645952d5 100644
--- a/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -710,18 +710,9 @@
beast_core\thread
-
- beast_core\thread
-
beast_core\thread
-
- beast_core\thread
-
-
- beast_core\thread
-
beast_core\thread
@@ -1390,15 +1381,9 @@
beast_core\thread
-
- beast_core\thread
-
beast_core\thread
-
- beast_core\thread
-
beast_core\thread
diff --git a/modules/beast_core/beast_core.cpp b/modules/beast_core/beast_core.cpp
index 0278a0890..9613d534b 100644
--- a/modules/beast_core/beast_core.cpp
+++ b/modules/beast_core/beast_core.cpp
@@ -220,8 +220,6 @@ namespace beast
#include "thread/beast_CallQueue.cpp"
#include "thread/beast_Listeners.cpp"
#include "thread/beast_ManualCallQueue.cpp"
-#include "thread/beast_ParallelFor.cpp"
-#include "thread/beast_ThreadGroup.cpp"
#include "thread/beast_ThreadWithCallQueue.cpp"
#include "thread/beast_Workers.cpp"
diff --git a/modules/beast_core/beast_core.h b/modules/beast_core/beast_core.h
index 497d9c4d0..e8a478fa4 100644
--- a/modules/beast_core/beast_core.h
+++ b/modules/beast_core/beast_core.h
@@ -418,13 +418,10 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "memory/beast_GlobalFifoFreeStore.h"
#include "thread/beast_Semaphore.h"
-#include "thread/beast_SerialFor.h"
#include "thread/beast_InterruptibleThread.h"
-#include "thread/beast_ThreadGroup.h"
#include "thread/beast_CallQueue.h"
#include "thread/beast_Listeners.h"
#include "thread/beast_ManualCallQueue.h"
-#include "thread/beast_ParallelFor.h"
#include "thread/beast_ThreadWithCallQueue.h"
#include "thread/beast_Workers.h"
diff --git a/modules/beast_core/thread/beast_OncePerSecond.cpp b/modules/beast_core/thread/beast_OncePerSecond.cpp
deleted file mode 100644
index 0fed5ec80..000000000
--- a/modules/beast_core/thread/beast_OncePerSecond.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-class OncePerSecond::TimerSingleton
- : public SharedSingleton
- , private InterruptibleThread::EntryPoint
-{
-public:
- TimerSingleton ()
- : SharedSingleton (
- SingletonLifetime::persistAfterCreation)
- , m_thread ("Once Per Second")
- {
- m_thread.start (this);
- }
-
- ~TimerSingleton ()
- {
- m_thread.join ();
-
- bassert (m_list.empty ());
- }
-
- void threadRun ()
- {
- for (;;)
- {
- bool const interrupted = m_thread.wait (1000);
-
- if (interrupted)
- break;
-
- notify ();
- }
- }
-
- void notify ()
- {
- CriticalSection::ScopedLockType lock (m_mutex);
-
- for (List ::iterator iter = m_list.begin (); iter != m_list.end ();)
- {
- OncePerSecond* object = iter->object;
- ++iter;
- object->doOncePerSecond ();
- }
- }
-
-public:
- void insert (Elem* elem)
- {
- CriticalSection::ScopedLockType lock (m_mutex);
-
- m_list.push_back (*elem);
- }
-
- void remove (Elem* elem)
- {
- CriticalSection::ScopedLockType lock (m_mutex);
-
- m_list.erase (m_list.iterator_to (*elem));
- }
-
- static TimerSingleton* createInstance ()
- {
- return new TimerSingleton;
- }
-
-private:
- InterruptibleThread m_thread;
- CriticalSection m_mutex;
- List m_list;
-};
-
-//------------------------------------------------------------------------------
-
-OncePerSecond::OncePerSecond ()
-{
- m_elem.instance = TimerSingleton::getInstance ();
- m_elem.object = this;
-}
-
-OncePerSecond::~OncePerSecond ()
-{
-}
-
-void OncePerSecond::startOncePerSecond ()
-{
- m_elem.instance->insert (&m_elem);
-}
-
-void OncePerSecond::endOncePerSecond ()
-{
- m_elem.instance->remove (&m_elem);
-}
diff --git a/modules/beast_core/thread/beast_OncePerSecond.h b/modules/beast_core/thread/beast_OncePerSecond.h
deleted file mode 100644
index bd13bcddc..000000000
--- a/modules/beast_core/thread/beast_OncePerSecond.h
+++ /dev/null
@@ -1,62 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef BEAST_ONCEPERSECOND_H_INCLUDED
-#define BEAST_ONCEPERSECOND_H_INCLUDED
-
-/*============================================================================*/
-/**
- Provides a once per second notification.
-
- Derive your class from OncePerSecond and override doOncePerSecond(). Then,
- call startOncePerSecond() to begin receiving the notifications. No clean-up
- or other actions are required.
-
- @ingroup beast_core
-*/
-class BEAST_API OncePerSecond : public Uncopyable
-{
-public:
- OncePerSecond ();
- virtual ~OncePerSecond ();
-
- /** Begin receiving notifications. */
- void startOncePerSecond ();
-
- /** Stop receiving notifications. */
- void endOncePerSecond ();
-
-protected:
- /** Called once per second. */
- virtual void doOncePerSecond () = 0;
-
-private:
- class TimerSingleton;
- typedef SharedPtr TimerPtr;
-
- struct Elem : List ::Node
- {
- TimerPtr instance;
- OncePerSecond* object;
- };
-
- Elem m_elem;
-};
-
-#endif
diff --git a/modules/beast_core/thread/beast_ParallelFor.cpp b/modules/beast_core/thread/beast_ParallelFor.cpp
deleted file mode 100644
index 62a9b9e6e..000000000
--- a/modules/beast_core/thread/beast_ParallelFor.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-ParallelFor::ParallelFor (ThreadGroup& pool)
- : m_pool (pool)
- , m_finishedEvent (false) // auto-reset
-{
-}
-
-int ParallelFor::getNumberOfThreads () const
-{
- return m_pool.getNumberOfThreads ();
-}
-
-void ParallelFor::doLoop (int numberOfIterations, Iteration& iteration)
-{
- if (numberOfIterations > 1)
- {
- int const numberOfThreads = m_pool.getNumberOfThreads ();
-
- // The largest number of pool threads we need is one less than the number
- // of iterations, because we also run the loop body on the caller's thread.
- //
- int const maxThreads = numberOfIterations - 1;
-
- // Calculate the number of parallel instances as the smaller of the number
- // of threads available (including the caller's) and the number of iterations.
- //
- int const numberOfParallelInstances = std::min (
- numberOfThreads + 1, numberOfIterations);
-
- LoopState* loopState (new (m_pool.getAllocator ()) LoopState (
- iteration, m_finishedEvent, numberOfIterations, numberOfParallelInstances));
-
- m_pool.call (maxThreads, &LoopState::forLoopBody, loopState);
-
- // Also use the caller's thread to run the loop body.
- loopState->forLoopBody ();
-
- m_finishedEvent.wait ();
- }
- else if (numberOfIterations == 1)
- {
- // Just one iteration, so do it.
- iteration (0);
- }
-}
diff --git a/modules/beast_core/thread/beast_ParallelFor.h b/modules/beast_core/thread/beast_ParallelFor.h
deleted file mode 100644
index 30dcc5099..000000000
--- a/modules/beast_core/thread/beast_ParallelFor.h
+++ /dev/null
@@ -1,250 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef BEAST_PARALLELFOR_H_INCLUDED
-#define BEAST_PARALLELFOR_H_INCLUDED
-
-/*============================================================================*/
-/**
- Parallel for loop.
-
- This uses a ThreadGroup to iterate through a for loop in parallel. The
- following two pieces of code perform identical operations:
-
- @code
-
- extern void function (int loopIndex);
-
- // Serial computation
- //
- for (int i = 0; i < numberOfIterations; ++i)
- function (i);
-
- // Parallel computation
- //
- ParallelFor().loop (numberOfIterations, &function);
-
- @endcode
-
- `function` is a caller provided functor. Convenience functions are provided
- for automatic binding to member or non member functions with up to 8
- arguments (not including the loop index).
-
- @note The last argument to function () is always the loop index.
-
- @see ThreadGroup
-
- @ingroup beast_concurrent
-*/
-class BEAST_API ParallelFor : public Uncopyable
-{
-public:
- /** Create a parallel for loop.
-
- It is best to keep this object around instead of creating and destroying
- it every time you need to run a loop.
-
- @param pool The ThreadGroup to use.
- */
- explicit ParallelFor (ThreadGroup& pool);
-
- /** Determine the number of threads in the group.
-
- @return The number of threads in the group.
- */
- int getNumberOfThreads () const;
-
- /** Execute parallel for loop.
-
- Functor is called once for each value in the range
- [0, numberOfIterations), using the ThreadGroup.
-
- @param numberOfIterations The number of times to loop.
-
- @param f The functor to call for each loop index.
- */
- /** @{ */
- template
- void loopf (int numberOfIterations, Functor const& f)
- {
- IterationType iteration (f);
-
- doLoop (numberOfIterations, iteration);
- }
-
-#if BEAST_VARIADIC_MAX >= 1
- template
- void loop (int n, Fn f)
- { loopf (n, functional::bind (f, placeholders::_1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 2
- template
- void loop (int n, Fn f, T1 t1)
- { loopf (n, functional::bind (f, t1, placeholders::_1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 3
- template
- void loop (int n, Fn f, T1 t1, T2 t2)
- { loopf (n, functional::bind (f, t1, t2, placeholders::_1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 4
- template
- void loop (int n, Fn f, T1 t1, T2 t2, T3 t3)
- { loopf (n, functional::bind (f, t1, t2, t3, placeholders::_1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 5
- template
- void loop (int n, Fn f, T1 t1, T2 t2, T3 t3, T4 t4)
- { loopf (n, functional::bind (f, t1, t2, t3, t4, placeholders::_1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 6
- template
- void loop (int n, Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
- { loopf (n, functional::bind (f, t1, t2, t3, t4, t5, placeholders::_1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 7
- template
- void loop (int n, Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
- { loopf (n, functional::bind (f, t1, t2, t3, t4, t5, t6, placeholders::_1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 8
- template
- void loop (int n, Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
- { loopf (n, functional::bind (f, t1, t2, t3, t4, t5, t6, t7, placeholders::_1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 9
- template
- void loop (int n, Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
- { loopf (n, functional::bind (f, t1, t2, t3, t4, t5, t6, t7, t8, placeholders::_1)); }
-#endif
- /** @} */
-
-private:
- class Iteration
- {
- public:
- virtual ~Iteration () { }
- virtual void operator () (int loopIndex) = 0;
- };
-
- template
- class IterationType : public Iteration, public Uncopyable
- {
- public:
- explicit IterationType (Functor const& f) : m_f (f)
- {
- }
-
- void operator () (int loopIndex)
- {
- m_f (loopIndex);
- }
-
- private:
- Functor m_f;
- };
-
-private:
- class LoopState
- : public AllocatedBy
- , public Uncopyable
- {
- private:
- Iteration& m_iteration;
- WaitableEvent& m_finishedEvent;
- int const m_numberOfIterations;
- Atomic m_loopIndex;
- Atomic m_iterationsRemaining;
- Atomic m_numberOfParallelInstances;
-
- public:
- LoopState (Iteration& iteration,
- WaitableEvent& finishedEvent,
- int numberOfIterations,
- int numberOfParallelInstances)
- : m_iteration (iteration)
- , m_finishedEvent (finishedEvent)
- , m_numberOfIterations (numberOfIterations)
- , m_loopIndex (-1)
- , m_iterationsRemaining (numberOfIterations)
- , m_numberOfParallelInstances (numberOfParallelInstances)
- {
- }
-
- ~LoopState ()
- {
- }
-
- void forLoopBody ()
- {
- for (;;)
- {
- // Request a loop index to process.
- int const loopIndex = ++m_loopIndex;
-
- // Is it in range?
- if (loopIndex < m_numberOfIterations)
- {
- // Yes, so process it.
- m_iteration (loopIndex);
-
- // Was this the last work item to complete?
- if (--m_iterationsRemaining == 0)
- {
- // Yes, signal.
- m_finishedEvent.signal ();
- break;
- }
- }
- else
- {
- // Out of range, all work is complete or assigned.
- break;
- }
- }
-
- release ();
- }
-
- void release ()
- {
- if (--m_numberOfParallelInstances == 0)
- delete this;
- }
- };
-
-private:
- void doLoop (int numberOfIterations, Iteration& iteration);
-
-private:
- ThreadGroup& m_pool;
- WaitableEvent m_finishedEvent;
- Atomic m_currentIndex;
- Atomic m_numberOfInstances;
-};
-
-#endif
diff --git a/modules/beast_core/thread/beast_SerialFor.h b/modules/beast_core/thread/beast_SerialFor.h
deleted file mode 100644
index 91de0178f..000000000
--- a/modules/beast_core/thread/beast_SerialFor.h
+++ /dev/null
@@ -1,71 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef BEAST_SERIALFOR_H_INCLUDED
-#define BEAST_SERIALFOR_H_INCLUDED
-
-/*============================================================================*/
-
-/** Serial for loop.
-
- Iterates a for loop sequentially. This is a drop in replacement for
- ParallelFor.
-
- @see ParallelFor
-
- @ingroup beast_core
-*/
-class BEAST_API SerialFor : public Uncopyable
-{
-public:
- /** Create a serial for loop.
- */
- inline SerialFor ()
- {
- }
-
- /** Determine the number of threads used to process loops.
-
- @return Always 1.
- */
- inline int getNumberOfThreads () const
- {
- return 1;
- }
-
- template
- inline void operator () (int numberOfIterations)
- {
- F f;
-
- for (int i = 0; i < numberOfIterations; ++i)
- f (i);
- }
-
- template
- inline void operator () (int numberOfIterations, T1 t1)
- {
- F f (t1);
-
- for (int i = 0; i < numberOfIterations; ++i)
- f (i);
- }
-};
-
-#endif
diff --git a/modules/beast_core/thread/beast_ThreadGroup.cpp b/modules/beast_core/thread/beast_ThreadGroup.cpp
deleted file mode 100644
index 1cce72781..000000000
--- a/modules/beast_core/thread/beast_ThreadGroup.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-void ThreadGroup::QuitType::operator () (Worker* worker)
-{
- worker->setShouldExit ();
-}
-
-//==============================================================================
-
-ThreadGroup::Worker::Worker (String name, ThreadGroup& group)
- : Thread (name)
- , m_group (group)
- , m_shouldExit (false)
-{
- startThread ();
-}
-
-ThreadGroup::Worker::~Worker ()
-{
- // Make sure the thread is stopped.
- stopThread (-1);
-}
-
-void ThreadGroup::Worker::setShouldExit ()
-{
- m_shouldExit = true;
-}
-
-void ThreadGroup::Worker::run ()
-{
- do
- {
- m_group.m_semaphore.wait ();
-
- Work* work = m_group.m_queue.pop_front ();
-
- bassert (work != nullptr);
-
- work->operator () (this);
-
- delete work;
- }
- while (!m_shouldExit);
-}
-
-//==============================================================================
-
-ThreadGroup::ThreadGroup (int numberOfThreads)
- : m_numberOfThreads (numberOfThreads)
- , m_semaphore (0)
-{
- for (int i = 0; i++ < numberOfThreads; )
- {
- String s;
- s << "ThreadGroup (" << i << ")";
-
- m_threads.push_front (new Worker (s, *this));
- }
-}
-
-ThreadGroup::~ThreadGroup ()
-{
- // Put one quit item in the queue for each worker to stop.
- for (int i = 0; i < m_numberOfThreads; ++i)
- {
- m_queue.push_front (new (getAllocator ()) QuitType);
-
- m_semaphore.signal ();
- }
-
- for (;;)
- {
- Worker* worker = m_threads.pop_front ();
-
- if (worker != nullptr)
- delete worker;
- else
- break;
- }
-
- // There must not be pending work!
- bassert (m_queue.pop_front () == nullptr);
-}
-
-int ThreadGroup::getNumberOfThreads () const
-{
- return m_numberOfThreads;
-}
diff --git a/modules/beast_core/thread/beast_ThreadGroup.h b/modules/beast_core/thread/beast_ThreadGroup.h
deleted file mode 100644
index 5e9a3e965..000000000
--- a/modules/beast_core/thread/beast_ThreadGroup.h
+++ /dev/null
@@ -1,215 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef BEAST_THREADGROUP_H_INCLUDED
-#define BEAST_THREADGROUP_H_INCLUDED
-
-/*============================================================================*/
-/**
- @ingroup beast_concurrent
-
- @brief A group of threads for parallelizing tasks.
-
- @see ParallelFor
-*/
-class BEAST_API ThreadGroup
-{
-public:
- typedef FifoFreeStoreType AllocatorType;
-
- /** Creates the specified number of threads.
-
- @param numberOfThreads The number of threads in the group. This must be
- greater than zero. If this parameter is omitted,
- one thread is created per available CPU.
- */
- explicit ThreadGroup (int numberOfThreads = SystemStats::getNumCpus ());
-
- ~ThreadGroup ();
-
- /** Allocator access.
- */
- inline AllocatorType& getAllocator ()
- {
- return m_allocator;
- }
-
- /** Determine the number of threads in the group.
-
- @return The number of threads in the group.
- */
- int getNumberOfThreads () const;
-
- /** Calls a functor on multiple threads.
-
- The specified functor is executed on some or all available threads at once.
- A call is always guaranteed to execute.
-
- @param maxThreads The maximum number of threads to use, or -1 for all.
-
- @param f The functor to call for each thread.
- */
- /** @{ */
- template
- void callf (int maxThreads, Functor f)
- {
- bassert (maxThreads > 0 || maxThreads == -1);
-
- int numberOfThreads = getNumberOfThreads ();
-
- if (maxThreads != -1 && maxThreads < numberOfThreads)
- numberOfThreads = maxThreads;
-
- while (numberOfThreads--)
- {
- m_queue.push_front (new (getAllocator ()) WorkType (f));
- m_semaphore.signal ();
- }
- }
-
-#if BEAST_VARIADIC_MAX >= 1
- template
- void call (int maxThreads, Fn f)
- { callf (maxThreads, functional::bind (f)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 2
- template
- void call (int maxThreads, Fn f, T1 t1)
- { callf (maxThreads, functional::bind (f, t1)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 3
- template
- void call (int maxThreads, Fn f, T1 t1, T2 t2)
- { callf (maxThreads, functional::bind (f, t1, t2)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 4
- template
- void call (int maxThreads, Fn f, T1 t1, T2 t2, T3 t3)
- { callf (maxThreads, functional::bind (f, t1, t2, t3)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 5
- template
- void call (int maxThreads, Fn f, T1 t1, T2 t2, T3 t3, T4 t4)
- { callf (maxThreads, functional::bind (f, t1, t2, t3, t4)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 6
- template
- void call (int maxThreads, Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
- { callf (maxThreads, functional::bind (f, t1, t2, t3, t4, t5)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 7
- template
- void call (int maxThreads, Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
- { callf (maxThreads, functional::bind (f, t1, t2, t3, t4, t5, t6)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 8
- template
- void call (int maxThreads, Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
- { callf (maxThreads, functional::bind (f, t1, t2, t3, t4, t5, t6, t7)); }
-#endif
-
-#if BEAST_VARIADIC_MAX >= 9
- template
- void call (int maxThreads, Fn f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
- { callf (maxThreads, functional::bind (f, t1, t2, t3, t4, t5, t6, t7, t8)); }
-#endif
- /** @} */
-
-private:
- void stopThreads (int numberOfThreadsToStop);
-
- //============================================================================
-private:
- /** A thread in the group.
- */
- class Worker
- : public LockFreeStack ::Node
- , public Thread
- , LeakChecked
- {
- public:
- Worker (String name, ThreadGroup& group);
- ~Worker ();
-
- void setShouldExit ();
-
- private:
- void run ();
-
- private:
- ThreadGroup& m_group;
- bool m_shouldExit;
- };
-
- //============================================================================
-private:
- /** Abstract work item.
- */
- class Work : public LockFreeStack ::Node
- , public AllocatedBy
- {
- public:
- virtual ~Work () { }
-
- /* The worker is passed in so we can make it quit later.
- */
- virtual void operator () (Worker* worker) = 0;
- };
-
- template
- class WorkType : public Work, LeakChecked >
- {
- public:
- explicit WorkType (Functor const& f) : m_f (f) { }
- ~WorkType () { }
- void operator () (Worker*)
- {
- m_f ();
- }
-
- private:
- Functor m_f;
- };
-
- /** Used to make a Worker stop
- */
- class QuitType
- : public Work
- , LeakChecked
- {
- public:
- void operator () (Worker* worker);
- };
-
-private:
- int const m_numberOfThreads;
- Semaphore m_semaphore;
- AllocatorType m_allocator;
- LockFreeStack m_queue;
- LockFreeStack m_threads;
-};
-
-#endif