BluFedora Job System v1.0.0
This is a C++ job system library for use in game engines.
Job::Splitter Struct Reference

#include <job_api.hpp>

Public Member Functions

constexpr bool operator() (const std::size_t count) const
 

Static Public Member Functions

static Splitter EvenSplit (const std::size_t total_num_items, std::size_t num_groups_per_thread=1u)
 Splits work evenly across the threads depending on the number of workers. More...
 
static constexpr Splitter MaxItemsPerTask (const std::size_t max_items)
 
template<typename T >
static constexpr Splitter MaxDataSize (const std::size_t max_data_size)
 

Public Attributes

std::size_t max_count = 0u
 

Detailed Description

Definition at line 522 of file job_api.hpp.

Member Function Documentation

◆ EvenSplit()

static Splitter Job::Splitter::EvenSplit ( const std::size_t  total_num_items,
std::size_t  num_groups_per_thread = 1u 
)
inlinestatic

Splits work evenly across the threads depending on the number of workers.

Ex: total_num_items = 400 num_groups_per_thread = 2 num_threads = 4

Leads to 8 groups of work each with 50 items. If num_groups_per_thread was changed to 1 then you will get 4 groups of work each with 100 items.

Parameters
total_num_itemsThe total number of items being processed.
num_groups_per_threadThe number of groups of items to be created per thread.
Returns
A splitter object for Job::ParallelFor.

Definition at line 545 of file job_api.hpp.

546 {
547 if (num_groups_per_thread < 1u)
548 {
549 num_groups_per_thread = 1u;
550 }
551
552 return Splitter{(total_num_items / num_groups_per_thread) / NumWorkers()};
553 }
std::uint16_t NumWorkers() noexcept
Returns the number of workers created by the system. This function can be called by any thread concur...
Definition: job_system.cpp:916

References Job::NumWorkers().

◆ MaxItemsPerTask()

static constexpr Splitter Job::Splitter::MaxItemsPerTask ( const std::size_t  max_items)
inlinestaticconstexpr

Definition at line 555 of file job_api.hpp.

556 {
557 return Splitter{max_items};
558 }

◆ MaxDataSize()

template<typename T >
static constexpr Splitter Job::Splitter::MaxDataSize ( const std::size_t  max_data_size)
inlinestaticconstexpr

Definition at line 561 of file job_api.hpp.

562 {
563 return Splitter{max_data_size / sizeof(T)};
564 }

◆ operator()()

constexpr bool Job::Splitter::operator() ( const std::size_t  count) const
inlineconstexpr

Definition at line 568 of file job_api.hpp.

568{ return count > max_count; }
std::size_t max_count
Definition: job_api.hpp:566

References max_count.

Member Data Documentation

◆ max_count

std::size_t Job::Splitter::max_count = 0u

Definition at line 566 of file job_api.hpp.

Referenced by operator()().


The documentation for this struct was generated from the following file: