| 12345678910111213141516171819202122232425262728 |
- #ifndef UTILITY_HPP
- #define UTILITY_HPP
- #include <cassert>
- #include <cstdint>
- #include <BS_thread_pool.hpp>
- template<size_t Align = 1>
- size_t alignment_round(size_t size, const size_t align = Align) {
- assert(std::popcount(align) == 1);
- if (size & (align - 1)) {
- size = (size + align) & ~(align - 1);
- }
- return size;
- }
- extern BS::thread_pool *g_thread_pool;
- template<typename Func>
- void thread_pool_detach_task(Func &&func) {
- g_thread_pool->detach_task(std::forward<Func>(func));
- }
- #define TP_DETACH(func) thread_pool_detach_task(func)
- #define TP_SYNC g_thread_pool->wait()
- #endif //UTILITY_HPP
|