Skip to content

Commit

Permalink
small perf fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kelbon committed Aug 8, 2024
1 parent 9d26aa9 commit 07d2bb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/kelcoro/operation_hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct KELCORO_CO_AWAIT_REQUIRED op_hash_t {

} // namespace noexport

// precondition: opeation can be executed
// precondition: operation can be executed
// e.g. it is not empty coroutine handle or empty std::function
template <typename T>
struct operation_hash {
Expand Down
8 changes: 5 additions & 3 deletions include/kelcoro/thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,15 @@ struct thread_pool {

// specialization for thread pool uses hash to maximize parallel execution
inline void attach_list(thread_pool& e, task_node* top) {
operation_hash_t hash = 0;
while (top) {
if (!top)
return;
operation_hash_t hash = calculate_operation_hash(top->task);
do {
task_node* next = top->next;
e.select_worker(hash).attach(top);
++hash;
top = next;
}
} while (top);
}

struct jump_on_thread_pool : private create_node_and_attach<thread_pool> {
Expand Down

0 comments on commit 07d2bb8

Please sign in to comment.