Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
threadpoolimpl.cc File Reference
#include <cstdio>
#include <cstdlib>
#include <list>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <spdlog/spdlog.h>
#include <scroom/assertions.hh>
#include <scroom/async-deleter.hh>
#include <scroom/logger.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

namespace  anonymous_namespace{threadpoolimpl.cc}
 ThreadList / ThreadWaiter.
 

Functions

template<typename T >
std::shared_ptr< T > anonymous_namespace{threadpoolimpl.cc}::NotifyThreadList (std::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
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: