|
Scroom
0.14
|
#include <threadpool.hh>

Classes | |
| struct | Job |
| class | PrivateData |
| class | Queue |
| class | WeakQueue |
Public Types | |
| using | Ptr = boost::shared_ptr< ThreadPool > |
| using | ThreadPtr = boost::shared_ptr< boost::thread > |
Public Member Functions | |
| ThreadPool (bool completeAllJobsBeforeDestruction=false) | |
| ThreadPool. More... | |
| ThreadPool (int count, bool completeAllJobsBeforeDestruction=false) | |
| ThreadPool (const ThreadPool &)=delete | |
| ThreadPool (ThreadPool &&)=delete | |
| ThreadPool | operator= (const ThreadPool &)=delete |
| ThreadPool | operator= (ThreadPool &&)=delete |
| ~ThreadPool () | |
| void | schedule (boost::function< void()> const &fn, int priority=defaultPriority, const Queue::Ptr &queue=defaultQueue()) |
| void | schedule (boost::function< void()> const &fn, const Queue::Ptr &queue) |
| template<typename T > | |
| void | schedule (boost::shared_ptr< T > fn, int priority=defaultPriority, const Queue::Ptr &queue=defaultQueue()) |
| template<typename T > | |
| void | schedule (boost::shared_ptr< T > fn, const Queue::Ptr &queue) |
| void | schedule (boost::function< void()> const &fn, int priority, const WeakQueue::Ptr &queue) |
| void | schedule (boost::function< void()> const &fn, const WeakQueue::Ptr &queue) |
| template<typename T > | |
| void | schedule (boost::shared_ptr< T > fn, int priority, WeakQueue::Ptr queue) |
| template<typename T > | |
| void | schedule (boost::shared_ptr< T > fn, WeakQueue::Ptr queue) |
| template<typename R > | |
| boost::unique_future< R > | schedule (boost::function< R()> const &fn, int priority=defaultPriority, const Queue::Ptr &queue=defaultQueue()) |
| template<typename R > | |
| boost::unique_future< R > | schedule (boost::function< R()> const &fn, const Queue::Ptr &queue) |
| template<typename R , typename T > | |
| boost::unique_future< R > | schedule (boost::shared_ptr< T > fn, int priority=defaultPriority, const Queue::Ptr &queue=defaultQueue()) |
| template<typename R , typename T > | |
| boost::unique_future< R > | schedule (boost::shared_ptr< T > fn, const Queue::Ptr &queue) |
| template<typename R > | |
| boost::unique_future< R > | schedule (boost::function< R()> const &fn, int priority, WeakQueue::Ptr queue) |
| template<typename R > | |
| boost::unique_future< R > | schedule (boost::function< R()> const &fn, WeakQueue::Ptr queue) |
| template<typename R , typename T > | |
| boost::unique_future< R > | schedule (boost::shared_ptr< T > fn, int priority, WeakQueue::Ptr queue) |
| template<typename R , typename T > | |
| boost::unique_future< R > | schedule (boost::shared_ptr< T > fn, WeakQueue::Ptr queue) |
| ThreadPtr | add () |
| std::vector< ThreadPtr > | add (int count) |
Static Public Member Functions | |
| static ThreadPool::Ptr | create (bool completeAllJobsBeforeDestruction=false) |
| static ThreadPool::Ptr | create (int count, bool completeAllJobsBeforeDestruction=false) |
Static Private Member Functions | |
| static void | work (const PrivateData::Ptr &priv) |
| static void | do_one (const PrivateData::Ptr &priv) |
| static Queue::Ptr | defaultQueue () |
Private Attributes | |
| std::list< ThreadPtr > | threads |
| PrivateData::Ptr | priv |
Static Private Attributes | |
| static const int | defaultPriority = PRIO_NORMAL |
Generic threadpool
A ThreadPool is basically a collection of threads you can schedule() work on.
| using ThreadPool::Ptr = boost::shared_ptr<ThreadPool> |
| using ThreadPool::ThreadPtr = boost::shared_ptr<boost::thread> |
|
explicit |
Create a ThreadPool with one thread for each core in the system
Referenced by CpuBound(), create(), and Sequentially().


|
explicit |
|
delete |
|
delete |
| ThreadPool::~ThreadPool | ( | ) |
Destructor
| ThreadPool::ThreadPtr ThreadPool::add | ( | ) |
Add an additional thread to the pool.
This is mostly used for testing
Referenced by add(), BOOST_AUTO_TEST_CASE(), and ThreadPool().


| std::vector< ThreadPool::ThreadPtr > ThreadPool::add | ( | int | count | ) |
Add the given number of threads to the pool.
This is mostly used for testing

|
static |
Create a ThreadPool with one thread for each core in the system
Referenced by BOOST_AUTO_TEST_CASE().


|
static |
|
staticprivate |

|
staticprivate |
|
delete |
|
delete |
| boost::unique_future< R > ThreadPool::schedule | ( | boost::function< R()> const & | fn, |
| const Queue::Ptr & | queue | ||
| ) |
| boost::unique_future< R > ThreadPool::schedule | ( | boost::function< R()> const & | fn, |
| int | priority, | ||
| WeakQueue::Ptr | queue | ||
| ) |

| boost::unique_future< R > ThreadPool::schedule | ( | boost::function< R()> const & | fn, |
| int | priority = defaultPriority, |
||
| const Queue::Ptr & | queue = defaultQueue() |
||
| ) |

| boost::unique_future< R > ThreadPool::schedule | ( | boost::function< R()> const & | fn, |
| WeakQueue::Ptr | queue | ||
| ) |
| void ThreadPool::schedule | ( | boost::function< void()> const & | fn, |
| const Queue::Ptr & | queue | ||
| ) |
Schedule the given job at the given queue

| void ThreadPool::schedule | ( | boost::function< void()> const & | fn, |
| const WeakQueue::Ptr & | queue | ||
| ) |
Schedule the given job at the given queue

| void ThreadPool::schedule | ( | boost::function< void()> const & | fn, |
| int | priority, | ||
| const WeakQueue::Ptr & | queue | ||
| ) |
| void ThreadPool::schedule | ( | boost::function< void()> const & | fn, |
| int | priority = defaultPriority, |
||
| const Queue::Ptr & | queue = defaultQueue() |
||
| ) |
Schedule the given job at the given priority
Referenced by BOOST_AUTO_TEST_CASE(), has_at_least_n_threads(), and schedule().

| void ThreadPool::schedule | ( | boost::shared_ptr< T > | fn, |
| const Queue::Ptr & | queue | ||
| ) |
Schedule the given job at the given priority

| boost::unique_future< R > ThreadPool::schedule | ( | boost::shared_ptr< T > | fn, |
| const Queue::Ptr & | queue | ||
| ) |
| void ThreadPool::schedule | ( | boost::shared_ptr< T > | fn, |
| int | priority, | ||
| WeakQueue::Ptr | queue | ||
| ) |
Schedule the given job at the given priority

| boost::unique_future< R > ThreadPool::schedule | ( | boost::shared_ptr< T > | fn, |
| int | priority, | ||
| WeakQueue::Ptr | queue | ||
| ) |

| void ThreadPool::schedule | ( | boost::shared_ptr< T > | fn, |
| int | priority = defaultPriority, |
||
| const Queue::Ptr & | queue = defaultQueue() |
||
| ) |
Schedule the given job at the given priority

| boost::unique_future< R > ThreadPool::schedule | ( | boost::shared_ptr< T > | fn, |
| int | priority = defaultPriority, |
||
| const Queue::Ptr & | queue = defaultQueue() |
||
| ) |
| void ThreadPool::schedule | ( | boost::shared_ptr< T > | fn, |
| WeakQueue::Ptr | queue | ||
| ) |
Schedule the given job at the given priority

| boost::unique_future< R > ThreadPool::schedule | ( | boost::shared_ptr< T > | fn, |
| WeakQueue::Ptr | queue | ||
| ) |

|
staticprivate |
This is executed by each of the threads in the ThreadPool
Those last two tasks will be performed by do_one()
Referenced by add().


|
staticprivate |
Referenced by schedule().
|
private |
Referenced by add(), do_one(), schedule(), work(), and ~ThreadPool().
|
private |
Threads in this ThreadPool
Referenced by add().