Go to the documentation of this file.
17 #include <boost/function.hpp>
18 #include <boost/shared_ptr.hpp>
19 #include <boost/thread.hpp>
82 using Ptr = boost::shared_ptr<Queue>;
101 boost::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl>
get();
102 boost::shared_ptr<WeakQueue>
getWeak();
112 boost::shared_ptr<WeakQueue>
weak;
137 using Ptr = boost::shared_ptr<WeakQueue>;
149 boost::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl>
get();
155 boost::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl>
qi;
161 boost::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl>
queue;
162 boost::function<void()>
fn;
169 using Ptr = boost::shared_ptr<ThreadPool>;
196 using Ptr = boost::shared_ptr<PrivateData>;
202 boost::condition_variable
cond;
212 std::map<int, std::queue<Job>>
jobs;
274 explicit ThreadPool(
bool completeAllJobsBeforeDestruction =
false);
277 explicit ThreadPool(
int count,
bool completeAllJobsBeforeDestruction =
false);
309 template <
typename T>
317 template <
typename T>
331 template <
typename T>
339 template <
typename T>
342 template <
typename R>
343 boost::unique_future<R>
346 template <
typename R>
347 boost::unique_future<R>
schedule(boost::function<R()>
const& fn,
const Queue::Ptr& queue);
349 template <
typename R,
typename T>
350 boost::unique_future<R>
353 template <
typename R,
typename T>
356 template <
typename R>
359 template <
typename R>
362 template <
typename R,
typename T>
365 template <
typename R,
typename T>
384 std::vector<ThreadPtr>
add(
int count);
537 using Ptr = boost::shared_ptr<QueueJumper>;
544 boost::function<void()>
fn;
571 bool setWork(boost::function<
void()>
const&
fn);
ThreadPool(bool completeAllJobsBeforeDestruction=false)
ThreadPool.
Definition: threadpoolimpl.cc:207
boost::shared_ptr< ThreadPool > Ptr
Definition: threadpool.hh:169
boost::shared_ptr< Queue > Ptr
Definition: threadpool.hh:82
@ PRIO_LOW
Definition: threadpool.hh:30
boost::mutex mut
Definition: threadpool.hh:200
boost::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > get()
Definition: threadpoolimpl.cc:388
boost::shared_ptr< WeakQueue > Ptr
Definition: threadpool.hh:137
bool inQueue
Definition: threadpool.hh:541
ThreadPool operator=(const ThreadPool &)=delete
Definition: threadpool.hh:46
static Ptr createAsync()
Definition: threadpoolimpl.cc:379
Definition: async-deleter.hh:21
static Ptr create(bool completeAllJobsBeforeDestruction)
Definition: threadpoolimpl.cc:198
bool setWork(boost::function< void()> const &fn)
Definition: threadpoolimpl.cc:421
Queue & operator=(const Queue &)=delete
Queue::Ptr defaultQueue
Definition: threadpool.hh:237
PrivateData(bool completeAllJobsBeforeDestruction)
ThreadPool::PrivateData.
Definition: threadpoolimpl.cc:192
Definition: threadpool.hh:159
ThreadPool::Ptr Sequentially()
Definition: threadpoolimpl.cc:459
@ PRIO_LOWEST
Definition: threadpool.hh:32
WeakQueue()
Definition: threadpoolimpl.cc:398
@ PRIO_LOWER
Definition: threadpool.hh:31
static Ptr create()
QueueJumper.
Definition: threadpoolimpl.cc:419
Definition: threadpool.hh:79
Definition: threadpool.hh:534
static const int defaultPriority
Definition: threadpool.hh:270
boost::shared_ptr< WeakQueue > weak
Definition: threadpool.hh:112
static Ptr create()
ThreadPool::Queue.
Definition: threadpoolimpl.cc:377
bool alive
Definition: threadpool.hh:201
boost::function< void()> fn
Definition: threadpool.hh:544
boost::shared_ptr< QueueJumper > Ptr
Definition: threadpool.hh:537
boost::weak_ptr< WeakQueue > WeakPtr
Definition: threadpool.hh:138
Definition: threadpool.hh:134
boost::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > get()
Definition: threadpoolimpl.cc:403
boost::condition_variable cond
Definition: threadpool.hh:202
static Queue::Ptr defaultQueue()
Definition: threadpoolimpl.cc:365
@ PRIO_HIGHEST
Definition: threadpool.hh:26
boost::mutex mut
Definition: threadpool.hh:540
ThreadPool::Ptr CpuBound()
Definition: threadpoolimpl.cc:452
boost::shared_ptr< WeakQueue > getWeak()
Definition: threadpoolimpl.cc:390
static Ptr create()
ThreadPool::WeakQueue.
Definition: threadpoolimpl.cc:396
bool completeAllJobsBeforeDestruction
Definition: threadpool.hh:220
static ThreadPool::Ptr create(bool completeAllJobsBeforeDestruction=false)
Definition: threadpoolimpl.cc:228
boost::shared_ptr< PrivateData > Ptr
Definition: threadpool.hh:196
std::map< int, std::queue< Job > > jobs
Definition: threadpool.hh:212
@ PRIO_HIGH
Definition: threadpool.hh:28
@ PRIO_HIGHER
Definition: threadpool.hh:27
WeakQueue & operator=(const WeakQueue &)=delete
boost::function< void()> fn
Definition: threadpool.hh:162
~Queue()
Definition: threadpoolimpl.cc:386
Queue()
Definition: threadpoolimpl.cc:381
Definition: threadpool.hh:193
boost::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > qi
Definition: threadpool.hh:155
static void do_one(const PrivateData::Ptr &priv)
Definition: threadpoolimpl.cc:308
ThreadPtr add()
Definition: threadpoolimpl.cc:238
boost::weak_ptr< Queue > WeakPtr
Definition: threadpool.hh:83
boost::shared_ptr< boost::thread > ThreadPtr
Definition: threadpool.hh:170
@ PRIO_NORMAL
Definition: threadpool.hh:29
static void work(const PrivateData::Ptr &priv)
Definition: threadpoolimpl.cc:273
void schedule(boost::function< void()> const &fn, int priority=defaultPriority, const Queue::Ptr &queue=defaultQueue())
Definition: threadpoolimpl.cc:342
bool isSet
Definition: threadpool.hh:542
PrivateData::Ptr priv
Definition: threadpool.hh:247
unsigned int jobcount
Definition: threadpool.hh:199
boost::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > queue
Definition: threadpool.hh:161
std::list< ThreadPtr > threads
Definition: threadpool.hh:246
~ThreadPool()
Definition: threadpoolimpl.cc:257
void operator()()
Definition: threadpoolimpl.cc:438