equal
deleted
inserted
replaced
34 private: |
34 private: |
35 volatile int* const _lock; |
35 volatile int* const _lock; |
36 bool _has_lock; |
36 bool _has_lock; |
37 |
37 |
38 public: |
38 public: |
39 JfrTryLock(volatile int* lock) : _lock(lock), _has_lock(Atomic::cmpxchg(1, lock, 0) == 0) {} |
39 JfrTryLock(volatile int* lock) : _lock(lock), _has_lock(Atomic::cmpxchg(lock, 0, 1) == 0) {} |
40 |
40 |
41 ~JfrTryLock() { |
41 ~JfrTryLock() { |
42 if (_has_lock) { |
42 if (_has_lock) { |
43 OrderAccess::fence(); |
43 OrderAccess::fence(); |
44 *_lock = 0; |
44 *_lock = 0; |