mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
CPU: update suspend interface (dummy)
This commit is contained in:
parent
190676c982
commit
e9f7c100a0
@ -836,7 +836,7 @@ std::string cpu_thread::dump_misc() const
|
|||||||
return fmt::format("Type: %s\n" "State: %s\n", typeid(*this).name(), state.load());
|
return fmt::format("Type: %s\n" "State: %s\n", typeid(*this).name(), state.load());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cpu_thread::suspend_work::push(cpu_thread* _this, bool cancel_if_not_suspended) noexcept
|
bool cpu_thread::suspend_work::push(cpu_thread* _this) noexcept
|
||||||
{
|
{
|
||||||
// Can't allow pre-set wait bit (it'd be a problem)
|
// Can't allow pre-set wait bit (it'd be a problem)
|
||||||
verify(HERE), !_this || !(_this->state & cpu_flag::wait);
|
verify(HERE), !_this || !(_this->state & cpu_flag::wait);
|
||||||
|
@ -125,6 +125,8 @@ public:
|
|||||||
{
|
{
|
||||||
// Task priority
|
// Task priority
|
||||||
u8 prio;
|
u8 prio;
|
||||||
|
bool cancel_if_not_suspended;
|
||||||
|
bool was_posted;
|
||||||
|
|
||||||
// Size of prefetch list workload
|
// Size of prefetch list workload
|
||||||
u32 prf_size;
|
u32 prf_size;
|
||||||
@ -140,16 +142,21 @@ public:
|
|||||||
suspend_work* next;
|
suspend_work* next;
|
||||||
|
|
||||||
// Internal method
|
// Internal method
|
||||||
bool push(cpu_thread* _this, bool cancel_if_not_suspended = false) noexcept;
|
bool push(cpu_thread* _this) noexcept;
|
||||||
|
|
||||||
|
// Called after suspend_post
|
||||||
|
void post() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Suspend all threads and execute op (may be executed by other thread than caller!)
|
// Suspend all threads and execute op (may be executed by other thread than caller!)
|
||||||
template <u8 Prio = 0, typename F>
|
template <u8 Prio = 0, typename F>
|
||||||
static auto suspend_all(cpu_thread* _this, std::initializer_list<void*> hints, F op)
|
static auto suspend_all(cpu_thread* _this, std::initializer_list<void*> hints, F op)
|
||||||
{
|
{
|
||||||
|
constexpr u8 prio = Prio > 3 ? 3 : Prio;
|
||||||
|
|
||||||
if constexpr (std::is_void_v<std::invoke_result_t<F>>)
|
if constexpr (std::is_void_v<std::invoke_result_t<F>>)
|
||||||
{
|
{
|
||||||
suspend_work work{Prio, ::size32(hints), hints.begin(), &op, nullptr, [](void* func, void*)
|
suspend_work work{prio, false, false, ::size32(hints), hints.begin(), &op, nullptr, [](void* func, void*)
|
||||||
{
|
{
|
||||||
std::invoke(*static_cast<F*>(func));
|
std::invoke(*static_cast<F*>(func));
|
||||||
}};
|
}};
|
||||||
@ -161,7 +168,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::invoke_result_t<F> result;
|
std::invoke_result_t<F> result;
|
||||||
|
|
||||||
suspend_work work{Prio, ::size32(hints), hints.begin(), &op, &result, [](void* func, void* res_buf)
|
suspend_work work{prio, false, false, ::size32(hints), hints.begin(), &op, &result, [](void* func, void* res_buf)
|
||||||
{
|
{
|
||||||
*static_cast<std::invoke_result_t<F>*>(res_buf) = std::invoke(*static_cast<F*>(func));
|
*static_cast<std::invoke_result_t<F>*>(res_buf) = std::invoke(*static_cast<F*>(func));
|
||||||
}};
|
}};
|
||||||
@ -171,18 +178,34 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <u8 Prio = 0, typename F>
|
||||||
|
static suspend_work suspend_post(cpu_thread* _this, std::initializer_list<void*> hints, F& op)
|
||||||
|
{
|
||||||
|
constexpr u8 prio = Prio > 3 ? 3 : Prio;
|
||||||
|
|
||||||
|
static_assert(std::is_void_v<std::invoke_result_t<F>>, "cpu_thread::suspend_post only supports void as return type");
|
||||||
|
|
||||||
|
return suspend_work{prio, false, true, ::size32(hints), hints.begin(), &op, nullptr, [](void* func, void*)
|
||||||
|
{
|
||||||
|
std::invoke(*static_cast<F*>(func));
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
// Push the workload only if threads are being suspended by suspend_all()
|
// Push the workload only if threads are being suspended by suspend_all()
|
||||||
template <u8 Prio = 0, typename F>
|
template <u8 Prio = 0, typename F>
|
||||||
static bool if_suspended(cpu_thread* _this, std::initializer_list<void*> hints, F op)
|
static bool if_suspended(cpu_thread* _this, std::initializer_list<void*> hints, F op)
|
||||||
{
|
{
|
||||||
static_assert(std::is_void_v<std::invoke_result_t<F>>, "Unimplemented (must return void)");
|
constexpr u8 prio = Prio > 3 ? 3 : Prio;
|
||||||
|
|
||||||
|
static_assert(std::is_void_v<std::invoke_result_t<F>>, "cpu_thread::if_suspended only supports void as return type");
|
||||||
|
|
||||||
{
|
{
|
||||||
suspend_work work{Prio, ::size32(hints), hints.begin(), &op, nullptr, [](void* func, void*)
|
suspend_work work{prio, true, false, ::size32(hints), hints.begin(), &op, nullptr, [](void* func, void*)
|
||||||
{
|
{
|
||||||
std::invoke(*static_cast<F*>(func));
|
std::invoke(*static_cast<F*>(func));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
return work.push(_this, true);
|
return work.push(_this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user