Thread island#

#include <pagmo/islands/thread_island.hpp>

class thread_island#

Thread island.

This class is a user-defined island (UDI) that will run evolutions in a separate thread of execution.

thread_island is the UDI type automatically selected by the constructors of island on non-POSIX platforms or when both the island’s problem and algorithm provide at least the basic thread safety guarantee.

explicit thread_island(bool use_pool)#

New in version 2.16.

Constructor with use_pool flag.

The use_pool flag signals whether or not this island should use a common thread pool shared by all islands.

Using a thread pool is more computationally-efficient, for at least two reasons:

  • it avoids runtime overhead when the number of islands evolving simultaneously is larger than the CPU count (e.g., in a large archipelago);

  • because the implementation uses the Intel TBB libraries, it integrates better with other pagmo facilities built on top of TBB (e.g., the thread_bfe batch fitness evaluator).

A thread pool however also introduces a serializing behaviour because the number of evolutions actually running at the same time is limited by the CPU count (whereas without the thread pool an unlimited number of evolutions can be active at the same time, albeit with a performance penalty).

Param use_pool

a boolean flag signalling whether or not a thread pool should be used by the island.


Default constructor, equivalent to the previous constructor with use_pool set to True.

std::string get_name() const#

Island’s name.


"Thread island".

std::string get_extra_info() const#

New in version 2.16.

Island’s extra info.


a string containing extra info about this island instance.

void run_evolve(island &isl) const#

Run an evolution.

This method will use copies of isl’s algorithm and population, obtained via pagmo::island::get_algorithm() and pagmo::island::get_population(), to evolve the input island’s population. The evolved population will be assigned to isl using pagmo::island::set_population(), and the algorithm used for the evolution will be assigned to isl using pagmo::island::set_algorithm().

Param isl

the island that will undergo evolution.

Exception std::invalid_argument

if isl’s algorithm or problem do not provide at least the basic thread safety guarantee.

Exception unspecified

any exception thrown by: