|
@@ -11,15 +11,6 @@ namespace {
|
|
|
|
|
|
|
|
std::atomic<Snapshot> g_snapshot{};
|
|
std::atomic<Snapshot> g_snapshot{};
|
|
|
std::atomic<Status> g_status{Status::notReady};
|
|
std::atomic<Status> g_status{Status::notReady};
|
|
|
-SRWLOCK g_publicationLock = SRWLOCK_INIT;
|
|
|
|
|
-
|
|
|
|
|
-/** Loading/validation happens before this short swap; no game or Host lock is taken here. */
|
|
|
|
|
-void publish_snapshot(Snapshot pending, Status status) noexcept {
|
|
|
|
|
- AcquireSRWLockExclusive(&g_publicationLock);
|
|
|
|
|
- g_snapshot.store(std::move(pending), std::memory_order_release);
|
|
|
|
|
- g_status.store(status, std::memory_order_release);
|
|
|
|
|
- ReleaseSRWLockExclusive(&g_publicationLock);
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
template <typename Value>
|
|
template <typename Value>
|
|
|
[[nodiscard]] std::span<const Value>
|
|
[[nodiscard]] std::span<const Value>
|
|
@@ -330,10 +321,12 @@ void initialize(void* module, const ExpectedIdentity& expected) noexcept {
|
|
|
std::shared_ptr<Catalog> pending;
|
|
std::shared_ptr<Catalog> pending;
|
|
|
Status result = Status::catalogInvalid;
|
|
Status result = Status::catalogInvalid;
|
|
|
if (load(module, expected, pending, result)) {
|
|
if (load(module, expected, pending, result)) {
|
|
|
- publish_snapshot(Snapshot(std::move(pending)), Status::ready);
|
|
|
|
|
|
|
+ g_snapshot.store(Snapshot(std::move(pending)), std::memory_order_release);
|
|
|
|
|
+ g_status.store(Status::ready, std::memory_order_release);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- publish_snapshot({}, result);
|
|
|
|
|
|
|
+ g_snapshot.store({}, std::memory_order_release);
|
|
|
|
|
+ g_status.store(result, std::memory_order_release);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** Keeps the published mapping when a catalog-authorized replacement cannot be authenticated. */
|
|
/** Keeps the published mapping when a catalog-authorized replacement cannot be authenticated. */
|
|
@@ -343,7 +336,8 @@ bool reload(void* module, const ExpectedIdentity& expected) noexcept {
|
|
|
if (!load(module, expected, pending, result)) {
|
|
if (!load(module, expected, pending, result)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- publish_snapshot(Snapshot(std::move(pending)), Status::ready);
|
|
|
|
|
|
|
+ g_snapshot.store(Snapshot(std::move(pending)), std::memory_order_release);
|
|
|
|
|
+ g_status.store(Status::ready, std::memory_order_release);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -368,7 +362,8 @@ bool reload(void* module) noexcept {
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
void shutdown() noexcept {
|
|
void shutdown() noexcept {
|
|
|
- publish_snapshot({}, Status::notReady);
|
|
|
|
|
|
|
+ g_snapshot.store({}, std::memory_order_release);
|
|
|
|
|
+ g_status.store(Status::notReady, std::memory_order_release);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Status status() noexcept {
|
|
Status status() noexcept {
|
|
@@ -957,12 +952,4 @@ const format::Slot* task_linked_objective_slot(const Catalog& catalog,
|
|
|
: nullptr;
|
|
: nullptr;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-CatalogPublicationGuard::CatalogPublicationGuard() noexcept {
|
|
|
|
|
- AcquireSRWLockShared(&g_publicationLock);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-CatalogPublicationGuard::~CatalogPublicationGuard() noexcept {
|
|
|
|
|
- ReleaseSRWLockShared(&g_publicationLock);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
} // namespace sunrise::state::activity_sdk
|
|
} // namespace sunrise::state::activity_sdk
|