diff options
| author | 2020-02-05 15:48:20 -0400 | |
|---|---|---|
| committer | 2020-06-18 16:29:15 -0400 | |
| commit | be320a9e10fda32a984b12cdfe3aaf09cc67b39a (patch) | |
| tree | f2bb28be6adc2a416b59393bb8f438636e9c79c1 /src/common/spin_lock.cpp | |
| parent | Tests: Add tests for fibers and refactor/fix Fiber class (diff) | |
| download | yuzu-be320a9e10fda32a984b12cdfe3aaf09cc67b39a.tar.gz yuzu-be320a9e10fda32a984b12cdfe3aaf09cc67b39a.tar.xz yuzu-be320a9e10fda32a984b12cdfe3aaf09cc67b39a.zip | |
Common: Polish Fiber class, add comments, asserts and more tests.
Diffstat (limited to 'src/common/spin_lock.cpp')
| -rw-r--r-- | src/common/spin_lock.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/spin_lock.cpp b/src/common/spin_lock.cpp index 8077b78d2..82a1d39ff 100644 --- a/src/common/spin_lock.cpp +++ b/src/common/spin_lock.cpp | |||
| @@ -43,4 +43,11 @@ void SpinLock::unlock() { | |||
| 43 | lck.clear(std::memory_order_release); | 43 | lck.clear(std::memory_order_release); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | bool SpinLock::try_lock() { | ||
| 47 | if (lck.test_and_set(std::memory_order_acquire)) { | ||
| 48 | return false; | ||
| 49 | } | ||
| 50 | return true; | ||
| 51 | } | ||
| 52 | |||
| 46 | } // namespace Common | 53 | } // namespace Common |