mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Make lf_queue<> compatible with atomic_wait
This commit is contained in:
parent
ca5f0444bf
commit
e39348ad96
@ -307,14 +307,25 @@ public:
|
||||
delete m_head.load();
|
||||
}
|
||||
|
||||
void wait() noexcept
|
||||
template <atomic_wait::op Flags = atomic_wait::op::eq>
|
||||
void wait(std::nullptr_t null = nullptr) noexcept
|
||||
{
|
||||
if (m_head == nullptr)
|
||||
{
|
||||
m_head.wait(nullptr);
|
||||
m_head.template wait<Flags>(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
const volatile void* observe() const noexcept
|
||||
{
|
||||
return m_head.load();
|
||||
}
|
||||
|
||||
explicit operator bool() const noexcept
|
||||
{
|
||||
return m_head != nullptr;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void push(Args&&... args)
|
||||
{
|
||||
@ -414,6 +425,18 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
namespace atomic_wait
|
||||
{
|
||||
template <typename T>
|
||||
inline __m128i default_mask<lf_queue<T>> = _mm_cvtsi64_si128(-1);
|
||||
|
||||
template <typename T>
|
||||
constexpr __m128i get_value(lf_queue<T>&, std::nullptr_t value = nullptr)
|
||||
{
|
||||
return _mm_setzero_si128();
|
||||
}
|
||||
}
|
||||
|
||||
// Concurrent linked list, elements remain until destroyed.
|
||||
template <typename T>
|
||||
class lf_bunch final
|
||||
|
@ -182,7 +182,7 @@ struct cpu_prof
|
||||
if (threads.empty())
|
||||
{
|
||||
// Wait for messages if no work (don't waste CPU)
|
||||
registered.wait();
|
||||
atomic_wait::list(registered).wait();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -8847,6 +8847,11 @@ struct spu_llvm_worker
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!prog->second)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
const auto& func = *prog->second;
|
||||
|
||||
// Get data start
|
||||
@ -8986,7 +8991,7 @@ struct spu_llvm
|
||||
{
|
||||
// Interrupt profiler thread and put it to sleep
|
||||
static_cast<void>(prof_mutex.reset());
|
||||
registered.wait();
|
||||
atomic_wait::list(registered).wait(); // TODO
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -9017,6 +9022,11 @@ struct spu_llvm
|
||||
// Push the workload
|
||||
(workers.begin() + (worker_index++ % worker_count))->registered.push(reinterpret_cast<u64>(_old), &func);
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < worker_count; i++)
|
||||
{
|
||||
(workers.begin() + i)->registered.push(0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr auto thread_name = "SPU LLVM"sv;
|
||||
|
@ -8,3 +8,5 @@ CHECK_SIZE_ALIGN(s128, 16, 16);
|
||||
|
||||
static_assert(be_t<u16>(1) + be_t<u32>(2) + be_t<u64>(3) == 6);
|
||||
static_assert(le_t<u16>(1) + le_t<u32>(2) + le_t<u64>(3) == 6);
|
||||
|
||||
static_assert(sizeof(nullptr) == sizeof(void*));
|
||||
|
Loading…
Reference in New Issue
Block a user