Fixed thread pool a bit

Use 128-bit allocator instead of queue.
When pool is full (128), threads just terminate as before.
This commit is contained in:
Nekotekina 2020-11-13 11:32:47 +03:00
parent e48f160a29
commit ab365fe494
4 changed files with 134 additions and 59 deletions

View file

@ -522,6 +522,8 @@ void cpu_thread::operator()()
s_tls_thread_slot = -1;
g_tls_current_cpu_thread = nullptr;
_this = nullptr;
}

View file

@ -206,6 +206,30 @@ namespace utils
return r;
}
inline u32 ctz128(u128 arg)
{
if (u64 lo = static_cast<u64>(arg))
{
return std::countr_zero<u64>(lo);
}
else
{
return std::countr_zero<u64>(arg >> 64) + 64;
}
}
inline u32 clz128(u128 arg)
{
if (u64 hi = static_cast<u64>(arg >> 64))
{
return std::countl_zero<u64>(hi);
}
else
{
return std::countl_zero<u64>(arg) + 64;
}
}
#elif defined(_MSC_VER)
inline void prefetch_read(const void* ptr)
{
@ -287,5 +311,29 @@ namespace utils
return r;
}
inline u32 ctz128(u128 arg)
{
if (!arg.lo)
{
return std::countr_zero(arg.hi) + 64u;
}
else
{
return std::countr_zero(arg.lo);
}
}
inline u32 clz128(u128 arg)
{
if (arg.hi)
{
return std::countl_zero(arg.hi);
}
else
{
return std::countl_zero(arg.lo) + 64;
}
}
#endif
} // namespace utils