Skip to content

Commit f5641d8

Browse files
committed
Improve: Reduce implicit conversions
1 parent e13c6ec commit f5641d8

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,9 @@ build_release/fork_union_nbody # run the benchmarks
433433
For C++ debug builds, consider using the VS Code debugger presets or the following commands:
434434

435435
```bash
436-
cmake --build build_debug --config Debug # build with Debug symbols
437-
build_debug/fork_union_test_cpp20 # run a single test executable
436+
cmake -B build_debug -D CMAKE_BUILD_TYPE=Debug
437+
cmake --build build_debug --config Debug # build with Debug symbols
438+
build_debug/fork_union_test_cpp20 # run a single test executable
438439
```
439440

440441
To include NUMA, Huge Pages, and other optimizations on Linux, make sure to install dependencies:

include/fork_union.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ struct prong {
338338
constexpr prong &operator=(prong &&) = default;
339339
constexpr prong &operator=(prong const &) = default;
340340

341-
explicit prong(task_index_t task, thread_index_t thread = 0) noexcept : task(task), thread(thread) {}
341+
explicit prong(task_index_t task, thread_index_t thread) noexcept : task(task), thread(thread) {}
342342

343343
inline operator task_index_t() const noexcept { return task; }
344344
};
@@ -365,7 +365,7 @@ struct colocated_prong {
365365
constexpr colocated_prong &operator=(colocated_prong const &) = default;
366366
constexpr colocated_prong &operator=(colocated_prong &&) = default;
367367

368-
explicit colocated_prong(task_index_t task, thread_index_t thread = 0, colocation_index_t colocation = 0) noexcept
368+
explicit colocated_prong(task_index_t task, thread_index_t thread, colocation_index_t colocation) noexcept
369369
: task(task), thread(thread), colocation(colocation) {}
370370

371371
colocated_prong(prong<index_t> const &prong) noexcept : task(prong.task), thread(prong.thread), colocation(0) {}
@@ -394,7 +394,7 @@ struct colocated_thread {
394394
constexpr colocated_thread &operator=(colocated_thread const &) = default;
395395
constexpr colocated_thread &operator=(colocated_thread &&) = default;
396396

397-
explicit colocated_thread(thread_index_t thread, colocation_index_t colocation = 0) noexcept
397+
explicit colocated_thread(thread_index_t thread, colocation_index_t colocation) noexcept
398398
: thread(thread), colocation(colocation) {}
399399

400400
inline operator thread_index_t() const noexcept { return thread; }
@@ -641,6 +641,9 @@ struct indexed_split {
641641
return {begin, count};
642642
}
643643

644+
inline index_t smallest_size() const noexcept { return quotient_; }
645+
inline index_t largest_size() const noexcept { return quotient_ + (remainder_ > 0); }
646+
644647
private:
645648
index_t quotient_ {0};
646649
index_t remainder_ {0};
@@ -1336,7 +1339,7 @@ class basic_pool {
13361339
template <typename fork_type_>
13371340
static void _call_as_lambda(punned_fork_context_t punned_lambda_pointer, thread_index_t thread_index) noexcept {
13381341
fork_type_ &lambda_object = *static_cast<fork_type_ *>(punned_lambda_pointer);
1339-
lambda_object(colocated_thread_t {thread_index});
1342+
lambda_object(colocated_thread_t {thread_index, 0});
13401343
}
13411344

13421345
/**
@@ -2442,6 +2445,7 @@ struct linux_colocated_pool {
24422445
using epoch_index_t = index_t; // ? A.k.a. number of previous API calls in [0, UINT_MAX)
24432446
using thread_index_t = index_t; // ? A.k.a. "core index" or "thread ID" in [0, threads_count)
24442447
using colocated_thread_t = colocated_thread<thread_index_t>;
2448+
using prong_t = colocated_prong<index_t>;
24452449

24462450
using punned_fork_context_t = void *; // ? Pointer to the on-stack lambda
24472451
using trampoline_t = void (*)(punned_fork_context_t, colocated_thread_t); // ? Wraps lambda's `operator()`

0 commit comments

Comments
 (0)