MCPcopy Create free account
hub / github.com/bshoshany/thread-pool / blocks

Method blocks

include/BS_thread_pool.hpp:584–602  ·  view source on GitHub ↗

* @brief Construct a `blocks` object with the given specifications. * * @param first_index_ The first index in the range. * @param index_after_last_ The index after the last index in the range. * @param num_blocks_ The desired number of blocks to divide the range into. */

Source from the content-addressed store, hash-verified

582 * @param num_blocks_ The desired number of blocks to divide the range into.
583 */
584 blocks(const T first_index_, const T index_after_last_, const std::size_t num_blocks_) noexcept : num_blocks(num_blocks_), first_index(first_index_), index_after_last(index_after_last_)
585 {
586 if (index_after_last > first_index)
587 {
588 const std::size_t total_size = static_cast<std::size_t>(index_after_last - first_index);
589 num_blocks = std::min(num_blocks, total_size);
590 block_size = total_size / num_blocks;
591 remainder = total_size % num_blocks;
592 if (block_size == 0)
593 {
594 block_size = 1;
595 num_blocks = (total_size > 1) ? total_size : 1;
596 }
597 }
598 else
599 {
600 num_blocks = 0;
601 }
602 }
603
604 /**
605 * @brief Get the index after the last index of a block.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected