mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
Improve match2 ctx context start
This commit is contained in:
parent
b83f1e7694
commit
e42ba05883
2 changed files with 11 additions and 2 deletions
|
@ -571,6 +571,9 @@ error_code sceNpMatching2ContextStart(SceNpMatching2ContextId ctxId)
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_FOUND;
|
return SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_FOUND;
|
||||||
|
|
||||||
|
if (!ctx->started.compare_and_swap_test(0, 1))
|
||||||
|
return SCE_NP_MATCHING2_ERROR_CONTEXT_ALREADY_STARTED;
|
||||||
|
|
||||||
if (ctx->context_callback)
|
if (ctx->context_callback)
|
||||||
{
|
{
|
||||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||||
|
@ -1095,6 +1098,9 @@ error_code sceNpMatching2ContextStartAsync(SceNpMatching2ContextId ctxId, u32 ti
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_FOUND;
|
return SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_FOUND;
|
||||||
|
|
||||||
|
if (!ctx->started.compare_and_swap_test(0, 1))
|
||||||
|
return SCE_NP_MATCHING2_ERROR_CONTEXT_ALREADY_STARTED;
|
||||||
|
|
||||||
if (ctx->context_callback)
|
if (ctx->context_callback)
|
||||||
{
|
{
|
||||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||||
|
@ -1693,9 +1699,10 @@ error_code sceNpMatching2ContextStop(SceNpMatching2ContextId ctxId)
|
||||||
const auto ctx = get_match2_context(ctxId);
|
const auto ctx = get_match2_context(ctxId);
|
||||||
|
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
{
|
|
||||||
return SCE_NP_MATCHING2_ERROR_INVALID_CONTEXT_ID;
|
return SCE_NP_MATCHING2_ERROR_INVALID_CONTEXT_ID;
|
||||||
}
|
|
||||||
|
if (!ctx->started.compare_and_swap_test(1, 0))
|
||||||
|
return SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED;
|
||||||
|
|
||||||
if (ctx->context_callback)
|
if (ctx->context_callback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -191,6 +191,8 @@ struct match2_ctx
|
||||||
static const u32 id_count = 255; // TODO: constant here?
|
static const u32 id_count = 255; // TODO: constant here?
|
||||||
SAVESTATE_INIT_POS(27);
|
SAVESTATE_INIT_POS(27);
|
||||||
|
|
||||||
|
atomic_t<u32> started = 0;
|
||||||
|
|
||||||
shared_mutex mutex;
|
shared_mutex mutex;
|
||||||
|
|
||||||
SceNpCommunicationId communicationId{};
|
SceNpCommunicationId communicationId{};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue