src/hotspot/share/jfr/recorder/storage/jfrStorageUtils.inline.hpp
changeset 54964 ec7d6d8effc7
parent 53244 9807daeb47c4
child 58154 060d9d139109
child 58863 c16ac7a2eba4
equal deleted inserted replaced
54963:a5f5e680ea32 54964:ec7d6d8effc7
    24 
    24 
    25 #ifndef SHARE_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP
    25 #ifndef SHARE_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP
    26 #define SHARE_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP
    26 #define SHARE_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP
    27 
    27 
    28 #include "jfr/recorder/storage/jfrStorageUtils.hpp"
    28 #include "jfr/recorder/storage/jfrStorageUtils.hpp"
       
    29 #include "runtime/thread.inline.hpp"
    29 
    30 
    30 template <typename T>
    31 template <typename T>
    31 inline bool UnBufferedWriteToChunk<T>::write(T* t, const u1* data, size_t size) {
    32 inline bool UnBufferedWriteToChunk<T>::write(T* t, const u1* data, size_t size) {
    32   _writer.write_unbuffered(data, size);
    33   _writer.write_unbuffered(data, size);
    33   _processed += size;
    34   _processed += size;
    73   const bool result = _operation.write(t, current_top, unflushed_size);
    74   const bool result = _operation.write(t, current_top, unflushed_size);
    74   t->set_top(current_top + unflushed_size);
    75   t->set_top(current_top + unflushed_size);
    75   return result;
    76   return result;
    76 }
    77 }
    77 
    78 
       
    79 template <typename Type>
       
    80 static void retired_sensitive_acquire(Type* t) {
       
    81   assert(t != NULL, "invariant");
       
    82   if (t->retired()) {
       
    83     return;
       
    84   }
       
    85   Thread* const thread = Thread::current();
       
    86   while (!t->try_acquire(thread)) {
       
    87     if (t->retired()) {
       
    88       return;
       
    89     }
       
    90   }
       
    91 }
       
    92 
       
    93 template <typename Operation>
       
    94 inline bool ExclusiveOp<Operation>::process(typename Operation::Type* t) {
       
    95   retired_sensitive_acquire(t);
       
    96   assert(t->acquired_by_self() || t->retired(), "invariant");
       
    97   // User is required to ensure proper release of the acquisition
       
    98   return MutexedWriteOp<Operation>::process(t);
       
    99 }
       
   100 
    78 template <typename Operation>
   101 template <typename Operation>
    79 inline bool DiscardOp<Operation>::process(typename Operation::Type* t) {
   102 inline bool DiscardOp<Operation>::process(typename Operation::Type* t) {
    80   assert(t != NULL, "invariant");
   103   assert(t != NULL, "invariant");
    81   const u1* const current_top = _mode == concurrent ? t->concurrent_top() : t->top();
   104   const u1* const current_top = _mode == concurrent ? t->concurrent_top() : t->top();
    82   const size_t unflushed_size = t->pos() - current_top;
   105   const size_t unflushed_size = t->pos() - current_top;