14#include <boost/function.hpp>
15#include <boost/thread.hpp>
78 using Ptr = std::shared_ptr<Queue>;
97 std::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl>
get();
98 std::shared_ptr<WeakQueue>
getWeak();
108 std::shared_ptr<WeakQueue>
weak;
133 using Ptr = std::shared_ptr<WeakQueue>;
145 std::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl>
get();
151 std::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl>
qi;
157 std::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl>
queue;
165 using Ptr = std::shared_ptr<ThreadPool>;
192 using Ptr = std::shared_ptr<PrivateData>;
198 boost::condition_variable
cond;
208 std::map<int, std::queue<Job>>
jobs;
270 explicit ThreadPool(
bool completeAllJobsBeforeDestruction =
false);
273 explicit ThreadPool(
int count,
bool completeAllJobsBeforeDestruction =
false);
305 template <
typename T>
313 template <
typename T>
327 template <
typename T>
335 template <
typename T>
338 template <
typename R>
339 boost::unique_future<R>
342 template <
typename R>
343 boost::unique_future<R>
schedule(boost::function<R()>
const& fn,
const Queue::Ptr& queue);
345 template <
typename R,
typename T>
346 boost::unique_future<R>
349 template <
typename R,
typename T>
352 template <
typename R>
353 boost::unique_future<R>
schedule(boost::function<R()>
const& fn,
int priority,
const WeakQueue::Ptr& queue);
355 template <
typename R>
358 template <
typename R,
typename T>
359 boost::unique_future<R>
schedule(
const std::shared_ptr<T>& fn,
int priority,
const WeakQueue::Ptr& queue);
361 template <
typename R,
typename T>
380 std::vector<ThreadPtr>
add(
int count);
533 using Ptr = std::shared_ptr<QueueJumper>;
567 bool setWork(boost::function<
void()>
const&
fn);
Definition threadpool.hh:531
bool isSet
Definition threadpool.hh:538
static Ptr create()
QueueJumper.
Definition threadpoolimpl.cc:422
std::shared_ptr< QueueJumper > Ptr
Definition threadpool.hh:533
bool setWork(boost::function< void()> const &fn)
Definition threadpoolimpl.cc:424
void operator()()
Definition threadpoolimpl.cc:441
bool inQueue
Definition threadpool.hh:537
boost::mutex mut
Definition threadpool.hh:536
boost::function< void()> fn
Definition threadpool.hh:540
Definition threadpool.hh:190
static Ptr create(bool completeAllJobsBeforeDestruction)
Definition threadpoolimpl.cc:201
boost::condition_variable cond
Definition threadpool.hh:198
Queue::Ptr defaultQueue
Definition threadpool.hh:233
std::map< int, std::queue< Job > > jobs
Definition threadpool.hh:208
std::shared_ptr< PrivateData > Ptr
Definition threadpool.hh:192
bool alive
Definition threadpool.hh:197
boost::mutex mut
Definition threadpool.hh:196
bool completeAllJobsBeforeDestruction
Definition threadpool.hh:216
unsigned int jobcount
Definition threadpool.hh:195
Definition threadpool.hh:76
Queue()
Definition threadpoolimpl.cc:384
~Queue()
Definition threadpoolimpl.cc:389
std::shared_ptr< Queue > Ptr
Definition threadpool.hh:78
std::shared_ptr< WeakQueue > getWeak()
Definition threadpoolimpl.cc:393
std::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > get()
Definition threadpoolimpl.cc:391
Queue & operator=(const Queue &)=delete
static Ptr createAsync()
Definition threadpoolimpl.cc:382
std::shared_ptr< WeakQueue > weak
Definition threadpool.hh:108
Queue(const Queue &)=delete
std::weak_ptr< Queue > WeakPtr
Definition threadpool.hh:79
static Ptr create()
ThreadPool::Queue.
Definition threadpoolimpl.cc:380
Queue & operator=(Queue &&)=delete
Definition threadpool.hh:131
std::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > get()
Definition threadpoolimpl.cc:406
WeakQueue(const WeakQueue &)=delete
WeakQueue()
Definition threadpoolimpl.cc:401
static Ptr create()
ThreadPool::WeakQueue.
Definition threadpoolimpl.cc:399
WeakQueue(WeakQueue &&)=delete
WeakQueue & operator=(WeakQueue &&)=delete
std::shared_ptr< WeakQueue > Ptr
Definition threadpool.hh:133
std::weak_ptr< WeakQueue > WeakPtr
Definition threadpool.hh:134
std::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > qi
Definition threadpool.hh:151
WeakQueue & operator=(const WeakQueue &)=delete
Definition threadpool.hh:43
std::list< ThreadPtr > threads
Definition threadpool.hh:242
std::shared_ptr< boost::thread > ThreadPtr
Definition threadpool.hh:166
ThreadPool operator=(const ThreadPool &)=delete
PrivateData::Ptr priv
Definition threadpool.hh:243
~ThreadPool()
Definition threadpoolimpl.cc:260
void schedule(boost::function< void()> const &fn, int priority=defaultPriority, const Queue::Ptr &queue=defaultQueue())
Definition threadpoolimpl.cc:345
ThreadPtr add()
Definition threadpoolimpl.cc:241
static Queue::Ptr defaultQueue()
Definition threadpoolimpl.cc:368
ThreadPool(const ThreadPool &)=delete
static void do_one(const PrivateData::Ptr &priv)
Definition threadpoolimpl.cc:311
static void work(const PrivateData::Ptr &priv)
Definition threadpoolimpl.cc:276
static ThreadPool::Ptr create(bool completeAllJobsBeforeDestruction=false)
Definition threadpoolimpl.cc:231
static const int defaultPriority
Definition threadpool.hh:266
ThreadPool(ThreadPool &&)=delete
ThreadPool operator=(ThreadPool &&)=delete
std::shared_ptr< ThreadPool > Ptr
Definition threadpool.hh:165
() void(clear(nullptr)+(5 *clear(nullptr)) *5)
Definition async-deleter.hh:22
const size_t count
Definition pageprovider-tests.cc:21
Definition threadpool.hh:156
std::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > queue
Definition threadpool.hh:157
boost::function< void()> fn
Definition threadpool.hh:158
ThreadPool::Ptr CpuBound()
Definition threadpoolimpl.cc:455
@ PRIO_LOWER
Definition threadpool.hh:27
@ PRIO_HIGHEST
Definition threadpool.hh:22
@ PRIO_HIGH
Definition threadpool.hh:24
@ PRIO_LOW
Definition threadpool.hh:26
@ PRIO_LOWEST
Definition threadpool.hh:28
@ PRIO_HIGHER
Definition threadpool.hh:23
@ PRIO_NORMAL
Definition threadpool.hh:25
ThreadPool::Ptr Sequentially()
Definition threadpoolimpl.cc:462