Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to M93 #3781

Merged
merged 14 commits into from
Sep 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Core - Use InterlockedCompareExchange for custom ref count reads
  • Loading branch information
amaitland committed Sep 3, 2021
commit 75cc347812482bf0806bec7f51fd2b02f6984520
8 changes: 6 additions & 2 deletions CefSharp.Core.Runtime/Internals/CefRefCountManaged.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,19 @@ class CefRefCountManaged
///
bool HasOneRef() const
{
return ref_count_ == 1;
LONG res = InterlockedCompareExchange(&ref_count_, 0, 0);

return res == 1;
}

///
// Returns true if the reference count is at least 1.
///
bool HasAtLeastOneRef() const
{
return ref_count_ > 0;
LONG res = InterlockedCompareExchange(&ref_count_, 0, 0);

return res > 0;
}

private:
Expand Down