src/hotspot/share/jfr/utilities/jfrTryLock.hpp
changeset 59252 623722a6aeb9
parent 53244 9807daeb47c4
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
    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;