Skip to content

Commit

Permalink
async: default threadpool cannot be inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
UkoeHB committed May 20, 2024
1 parent 38b0fc2 commit e45a5ac
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/async/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ class Mutex final
std::atomic<std::thread::id> m_mutex_owner{std::thread::id{}};
};

} //namespace asyc
} //namespace async
2 changes: 1 addition & 1 deletion src/async/parent_reference_tasking_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,4 @@ class ThreadPool final
std::atomic<std::uint16_t> m_submit_rotation_counter{0};
};

} //namespace asyc
} //namespace async
2 changes: 1 addition & 1 deletion src/async/scoped_notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ class ScopedNotification final
std::function<void()> m_notification_func;
};

} //namespace asyc
} //namespace async
2 changes: 1 addition & 1 deletion src/async/sleepy_task_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ class SleepyTaskQueue final
std::mutex m_mutex;
};

} //namespace asyc
} //namespace async
2 changes: 1 addition & 1 deletion src/async/task_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,4 @@ void unclaim_sleeping_task(SleepingTask &sleeping_task_inout);
void reserve_sleeping_task(SleepingTask &sleeping_task_inout);
void kill_sleeping_task(SleepingTask &sleeping_task_inout);

} //namespace asyc
} //namespace async
11 changes: 11 additions & 0 deletions src/async/threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,4 +800,15 @@ void Threadpool::shut_down() noexcept
m_waiter_manager.shut_down();
}
//-------------------------------------------------------------------------------------------------------------------
Threadpool& get_default_threadpool()
{
static Threadpool default_threadpool{
static_cast<unsigned char>(DefaultPriorityLevels::MIN),
static_cast<uint16_t>(std::max(2u, std::thread::hardware_concurrency()) - 1),
20,
std::chrono::milliseconds(500)
};
return default_threadpool;
}
//-------------------------------------------------------------------------------------------------------------------
} //namespace async
15 changes: 3 additions & 12 deletions src/async/threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,6 @@ enum DefaultPriorityLevels : unsigned char
};

/// default threadpool
inline Threadpool& get_default_threadpool()
{
static Threadpool default_threadpool{
static_cast<unsigned char>(DefaultPriorityLevels::MIN),
static_cast<uint16_t>(std::max(2u, std::thread::hardware_concurrency()) - 1),
20,
std::chrono::milliseconds(500)
};
return default_threadpool;
}

} //namespace asyc
Threadpool& get_default_threadpool();

} //namespace async
2 changes: 1 addition & 1 deletion src/async/token_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ class TokenQueue final
bool m_is_shutting_down{false};
};

} //namespace asyc
} //namespace async
2 changes: 1 addition & 1 deletion src/async/waiter_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ class WaiterManager final
std::vector<ConditionalWaiterContext> m_conditional_waiters;
};

} //namespace asyc
} //namespace async

0 comments on commit e45a5ac

Please sign in to comment.