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 526 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 549 of file job_api.hpp.

550 {
551 if (num_groups_per_thread < 1u)
552 {
553 num_groups_per_thread = 1u;
554 }
555
556 return Splitter{(total_num_items / num_groups_per_thread) / NumWorkers()};
557 }
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:918

References Job::NumWorkers().

◆ MaxItemsPerTask()

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

Definition at line 559 of file job_api.hpp.

560 {
561 return Splitter{max_items};
562 }

◆ MaxDataSize()

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

Definition at line 565 of file job_api.hpp.

566 {
567 return Splitter{max_data_size / sizeof(T)};
568 }

◆ operator()()

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

Definition at line 572 of file job_api.hpp.

572{ return count > max_count; }
std::size_t max_count
Definition: job_api.hpp:570

References max_count.

Member Data Documentation

◆ max_count

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

Definition at line 570 of file job_api.hpp.

Referenced by operator()().


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