src/share/vm/jfr/recorder/storage/jfrStorageUtils.inline.hpp

changeset 9928
d2c2cd90513e
parent 9858
b985cbb00e68
     1.1 --- a/src/share/vm/jfr/recorder/storage/jfrStorageUtils.inline.hpp	Mon Jun 15 20:21:56 2020 +0100
     1.2 +++ b/src/share/vm/jfr/recorder/storage/jfrStorageUtils.inline.hpp	Wed Jun 17 11:43:05 2020 +0300
     1.3 @@ -26,6 +26,7 @@
     1.4  #define SHARE_VM_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP
     1.5  
     1.6  #include "jfr/recorder/storage/jfrStorageUtils.hpp"
     1.7 +#include "runtime/thread.inline.hpp"
     1.8  
     1.9  template <typename T>
    1.10  inline bool UnBufferedWriteToChunk<T>::write(T* t, const u1* data, size_t size) {
    1.11 @@ -75,6 +76,28 @@
    1.12    return result;
    1.13  }
    1.14  
    1.15 +template <typename Type>
    1.16 +static void retired_sensitive_acquire(Type* t) {
    1.17 +  assert(t != NULL, "invariant");
    1.18 +  if (t->retired()) {
    1.19 +    return;
    1.20 +  }
    1.21 +  Thread* const thread = Thread::current();
    1.22 +  while (!t->try_acquire(thread)) {
    1.23 +    if (t->retired()) {
    1.24 +      return;
    1.25 +    }
    1.26 +  }
    1.27 +}
    1.28 +
    1.29 +template <typename Operation>
    1.30 +inline bool ExclusiveOp<Operation>::process(typename Operation::Type* t) {
    1.31 +  retired_sensitive_acquire(t);
    1.32 +  assert(t->acquired_by_self() || t->retired(), "invariant");
    1.33 +  // User is required to ensure proper release of the acquisition
    1.34 +  return MutexedWriteOp<Operation>::process(t);
    1.35 +}
    1.36 +
    1.37  template <typename Operation>
    1.38  inline bool DiscardOp<Operation>::process(typename Operation::Type* t) {
    1.39    assert(t != NULL, "invariant");

mercurial