Browse Source
Merge pull request #6975 from ogniK5377/acc-async-ctx
Merge pull request #6975 from ogniK5377/acc-async-ctx
account: EnsureTokenIdCacheAsyncpull/15/merge
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 154 additions and 19 deletions
-
2src/core/CMakeLists.txt
-
66src/core/hle/service/acc/acc.cpp
-
68src/core/hle/service/acc/async_context.cpp
-
37src/core/hle/service/acc/async_context.h
@ -0,0 +1,68 @@ |
|||
// Copyright 2021 yuzu emulator team
|
|||
// Licensed under GPLv2 or any later version
|
|||
// Refer to the license.txt file included.
|
|||
|
|||
#include "core/core.h"
|
|||
#include "core/hle/ipc_helpers.h"
|
|||
#include "core/hle/service/acc/async_context.h"
|
|||
|
|||
namespace Service::Account { |
|||
IAsyncContext::IAsyncContext(Core::System& system_) |
|||
: ServiceFramework{system_, "IAsyncContext"}, compeletion_event{system_.Kernel()} { |
|||
|
|||
Kernel::KAutoObject::Create(std::addressof(compeletion_event)); |
|||
compeletion_event.Initialize("IAsyncContext:CompletionEvent"); |
|||
|
|||
// clang-format off
|
|||
static const FunctionInfo functions[] = { |
|||
{0, &IAsyncContext::GetSystemEvent, "GetSystemEvent"}, |
|||
{1, &IAsyncContext::Cancel, "Cancel"}, |
|||
{2, &IAsyncContext::HasDone, "HasDone"}, |
|||
{3, &IAsyncContext::GetResult, "GetResult"}, |
|||
}; |
|||
// clang-format on
|
|||
|
|||
RegisterHandlers(functions); |
|||
} |
|||
|
|||
void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { |
|||
LOG_DEBUG(Service_ACC, "called"); |
|||
|
|||
IPC::ResponseBuilder rb{ctx, 2, 1}; |
|||
rb.Push(ResultSuccess); |
|||
rb.PushCopyObjects(compeletion_event.GetReadableEvent()); |
|||
} |
|||
|
|||
void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) { |
|||
LOG_DEBUG(Service_ACC, "called"); |
|||
|
|||
Cancel(); |
|||
MarkComplete(); |
|||
|
|||
IPC::ResponseBuilder rb{ctx, 2}; |
|||
rb.Push(ResultSuccess); |
|||
} |
|||
|
|||
void IAsyncContext::HasDone(Kernel::HLERequestContext& ctx) { |
|||
LOG_DEBUG(Service_ACC, "called"); |
|||
|
|||
is_complete.store(IsComplete()); |
|||
|
|||
IPC::ResponseBuilder rb{ctx, 3}; |
|||
rb.Push(ResultSuccess); |
|||
rb.Push(is_complete.load()); |
|||
} |
|||
|
|||
void IAsyncContext::GetResult(Kernel::HLERequestContext& ctx) { |
|||
LOG_DEBUG(Service_ACC, "called"); |
|||
|
|||
IPC::ResponseBuilder rb{ctx, 3}; |
|||
rb.Push(GetResult()); |
|||
} |
|||
|
|||
void IAsyncContext::MarkComplete() { |
|||
is_complete.store(true); |
|||
compeletion_event.GetWritableEvent().Signal(); |
|||
} |
|||
|
|||
} // namespace Service::Account
|
|||
@ -0,0 +1,37 @@ |
|||
// Copyright 2021 yuzu emulator team |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include <atomic> |
|||
#include "core/hle/kernel/k_event.h" |
|||
#include "core/hle/service/service.h" |
|||
|
|||
namespace Core { |
|||
class System; |
|||
} |
|||
|
|||
namespace Service::Account { |
|||
|
|||
class IAsyncContext : public ServiceFramework<IAsyncContext> { |
|||
public: |
|||
explicit IAsyncContext(Core::System& system_); |
|||
|
|||
void GetSystemEvent(Kernel::HLERequestContext& ctx); |
|||
void Cancel(Kernel::HLERequestContext& ctx); |
|||
void HasDone(Kernel::HLERequestContext& ctx); |
|||
void GetResult(Kernel::HLERequestContext& ctx); |
|||
|
|||
protected: |
|||
virtual bool IsComplete() const = 0; |
|||
virtual void Cancel() = 0; |
|||
virtual ResultCode GetResult() const = 0; |
|||
|
|||
void MarkComplete(); |
|||
|
|||
std::atomic<bool> is_complete{false}; |
|||
Kernel::KEvent compeletion_event; |
|||
}; |
|||
|
|||
} // namespace Service::Account |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue