Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
threadpool.hh File Reference
#include <memory>
#include <queue>
#include <vector>
#include <boost/function.hpp>
#include <boost/thread.hpp>
#include <scroom/semaphore.hh>
#include <scroom/impl/threadpoolimpl.hh>
Include dependency graph for threadpool.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ThreadPool
 
class  ThreadPool::Queue
 
class  ThreadPool::WeakQueue
 
struct  ThreadPool::Job
 
class  ThreadPool::PrivateData
 
class  QueueJumper
 

Namespaces

namespace  Scroom
 
namespace  Scroom::Detail
 
namespace  Scroom::Detail::ThreadPool
 

Enumerations

enum  {
  PRIO_HIGHEST = 100 , PRIO_HIGHER , PRIO_HIGH , PRIO_NORMAL ,
  PRIO_LOW , PRIO_LOWER , PRIO_LOWEST
}
 

Functions

ThreadPool::Ptr CpuBound ()
 
ThreadPool::Ptr Sequentially ()
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Priorities for scheduling on the ThreadPool

Enumerator
PRIO_HIGHEST 
PRIO_HIGHER 
PRIO_HIGH 
PRIO_NORMAL 
PRIO_LOW 
PRIO_LOWER 
PRIO_LOWEST 
21{
22 PRIO_HIGHEST = 100,
29};
@ 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

Function Documentation

◆ CpuBound()

ThreadPool::Ptr CpuBound ( )

ThreadPool for cpu-bound tasks

This ThreadPool has one thread per core in your system. For CpuBound tasks, this is the optimum. Make sure your tasks do not block or wait for anything.

Returns
a shared pointer to this ThreadPool instance
See also
https://github.com/kees-jan/scroom/wiki/StaticInitializationOrderFiasco
456{
457 static ThreadPool::Ptr const cpuBound = NotifyThreadList<ThreadPool>(std::make_shared<ThreadPool>(), "CpuBound threadpool");
458
459 return cpuBound;
460}
std::shared_ptr< ThreadPool > Ptr
Definition threadpool.hh:165

Referenced by Layer::fetchData(), CompressedTile::observerAdded(), and LayerCoordinator::tileFinished().

Here is the caller graph for this function:

◆ Sequentially()

ThreadPool::Ptr Sequentially ( )

ThreadPool for executing tasks sequentially

Tasks that are cpu and/or memory intensive (think "loading large bitmaps") are typically scheduled here, such that only one such task runs at a time.

Note that it is rare to do any actual work on this thread. Especially the cpu-intensive tasks are best delegated to CpuBound(). On this thread, you just wait for the work to complete.

Returns
a shared pointer to this ThreadPool instance
See also
https://github.com/kees-jan/scroom/wiki/StaticInitializationOrderFiasco
463{
464 static ThreadPool::Ptr const sequentially =
465 NotifyThreadList<ThreadPool>(std::make_shared<ThreadPool>(1), "Sequential threadpool");
466
467 return sequentially;
468}

Referenced by PipetteHandler::onSelectionEnd(), WaitForAsyncOp::operator()(), and Scroom::TiledBitmap::scheduleLoadingBitmap().

Here is the caller graph for this function: