class mrpt::WorkerThreadsPool

A thread pool.

Partly based on: (ZLib license)

(New in MRPT 2.1.0)

#include <mrpt/core/WorkerThreadsPool.h>

class WorkerThreadsPool
    // enums

    enum queue_policy_t;

    // construction


        std::size_t num_threads,
        queue_policy_t p = POLICY_FIFO,
        const std::string& threadsName = "WorkerThreadsPool"


    void resize(std::size_t num_threads);
    void clear();

    template <class F, class... Args>
    auto enqueue(F&& f, Args&&... args);

    std::size_t pendingTasks() const;
    void name(const std::string& name);
    std::string name() const;


void clear()

Stops and deletes all worker threads.

template <class F, class... Args>
auto enqueue(F&& f, Args&&... args)

Enqueue one new working item, to be executed by threads when any is available.

std::size_t pendingTasks() const

Returns the number of enqueued tasks, currently waiting for a free working thread to process them.

void name(const std::string& name)

Sets the private thread names of threads in this pool.

Names can be seen from debuggers, profilers, etc. and will follow the format ${name}[i] with ${name} the value supplied in this method (Method new in MRPT 2.1.5)

std::string name() const

Returns the base name of threads in this pool.