Made the ID system thread safe

This commit is contained in:
SMJSGaming 2024-08-13 10:11:54 +02:00
parent a5bbf6a40c
commit 58402e9b7b
2 changed files with 3 additions and 3 deletions

View file

@ -112,7 +112,7 @@ namespace geode::utils::web {
private:
class Impl;
static size_t m_idCounter;
static std::atomic_size_t s_idCounter;
std::shared_ptr<Impl> m_impl;
const size_t m_id;
public:

View file

@ -212,9 +212,9 @@ public:
}
};
size_t WebRequest::m_idCounter = 0;
std::atomic_size_t WebRequest::s_idCounter = 0;
WebRequest::WebRequest() : m_impl(std::make_shared<Impl>()), m_id(WebRequest::m_idCounter++) {}
WebRequest::WebRequest() : m_impl(std::make_shared<Impl>()), m_id(WebRequest::s_idCounter++) {}
WebRequest::~WebRequest() {}
// Encodes a url param