Scroom  0.14
threadpoolimpl.cc File Reference
#include <cstdio>
#include <cstdlib>
#include <list>
#include <string>
#include <utility>
#include <vector>
#include <spdlog/spdlog.h>
#include <scroom/assertions.hh>
#include <scroom/async-deleter.hh>
#include <scroom/threadpool.hh>
#include "queue.hh"
Include dependency graph for threadpoolimpl.cc:

Classes

class  anonymous_namespace{threadpoolimpl.cc}::ThreadList
 
class  anonymous_namespace{threadpoolimpl.cc}::ThreadWaiter
 

Namespaces

 anonymous_namespace{threadpoolimpl.cc}
 ThreadList / ThreadWaiter.
 

Functions

template<typename T >
boost::shared_ptr< T > anonymous_namespace{threadpoolimpl.cc}::NotifyThreadList (boost::shared_ptr< T > t, const std::string &s)
 
ThreadPool::Ptr CpuBound ()
 
ThreadPool::Ptr Sequentially ()
 

Variables

ThreadWaiter anonymous_namespace{threadpoolimpl.cc}::waiter
 

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
453 {
454  static ThreadPool::Ptr const cpuBound = NotifyThreadList<ThreadPool>(ThreadPool::Ptr(new ThreadPool()), "CpuBound threadpool");
455 
456  return cpuBound;
457 }

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

Here is the call graph for this function:
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
460 {
461  static ThreadPool::Ptr const sequentially =
462  NotifyThreadList<ThreadPool>(ThreadPool::Ptr(new ThreadPool(1)), "Sequential threadpool");
463 
464  return sequentially;
465 }

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

Here is the call graph for this function:
Here is the caller graph for this function:
ThreadPool::Ptr
boost::shared_ptr< ThreadPool > Ptr
Definition: threadpool.hh:169
ThreadPool
Definition: threadpool.hh:46