Commit 480ee07d authored by Tsuyoshi Horo's avatar Tsuyoshi Horo Committed by Commit Bot

Use std::atomic_ulong for CreateUniqueIdentifier()

We will use CreateUniqueIdentifier() from worker threads when off-main-thread-fetch is enabled.
So g_unique_identifier must be atomic.

Bug: 443374
Change-Id: I766f466c250a90a8e2e61c8ac5535d3144a909b6
Reviewed-on: https://chromium-review.googlesource.com/593467
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490829}
parent 408e5cd8
......@@ -28,14 +28,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <atomic>
#include "platform/loader/fetch/UniqueIdentifier.h"
namespace blink {
static unsigned long g_unique_identifier = 0;
static std::atomic_ulong g_unique_identifier(1);
unsigned long CreateUniqueIdentifier() {
return ++g_unique_identifier;
return g_unique_identifier.fetch_add(1, std::memory_order_relaxed);
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment