|
1 /* |
|
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 #ifndef SHARE_VM_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP |
|
26 #define SHARE_VM_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP |
|
27 |
|
28 #include "jfr/recorder/storage/jfrStorageUtils.hpp" |
|
29 |
|
30 template <typename T> |
|
31 inline bool UnBufferedWriteToChunk<T>::write(T* t, const u1* data, size_t size) { |
|
32 _writer.write_unbuffered(data, size); |
|
33 _processed += size; |
|
34 return true; |
|
35 } |
|
36 |
|
37 template <typename T> |
|
38 inline bool DefaultDiscarder<T>::discard(T* t, const u1* data, size_t size) { |
|
39 _processed += size; |
|
40 return true; |
|
41 } |
|
42 |
|
43 template <typename Operation> |
|
44 inline bool ConcurrentWriteOp<Operation>::process(typename Operation::Type* t) { |
|
45 const u1* const current_top = t->concurrent_top(); |
|
46 const size_t unflushed_size = t->pos() - current_top; |
|
47 if (unflushed_size == 0) { |
|
48 t->set_concurrent_top(current_top); |
|
49 return true; |
|
50 } |
|
51 const bool result = _operation.write(t, current_top, unflushed_size); |
|
52 t->set_concurrent_top(current_top + unflushed_size); |
|
53 return result; |
|
54 } |
|
55 |
|
56 template <typename Operation> |
|
57 inline bool ConcurrentWriteOpExcludeRetired<Operation>::process(typename Operation::Type* t) { |
|
58 if (t->retired()) { |
|
59 assert(t->empty(), "invariant"); |
|
60 return true; |
|
61 } |
|
62 return ConcurrentWriteOp<Operation>::process(t); |
|
63 } |
|
64 |
|
65 template <typename Operation> |
|
66 inline bool MutexedWriteOp<Operation>::process(typename Operation::Type* t) { |
|
67 assert(t != NULL, "invariant"); |
|
68 const u1* const current_top = t->top(); |
|
69 const size_t unflushed_size = t->pos() - current_top; |
|
70 if (unflushed_size == 0) { |
|
71 return true; |
|
72 } |
|
73 const bool result = _operation.write(t, current_top, unflushed_size); |
|
74 t->set_top(current_top + unflushed_size); |
|
75 return result; |
|
76 } |
|
77 |
|
78 template <typename Operation> |
|
79 inline bool DiscardOp<Operation>::process(typename Operation::Type* t) { |
|
80 assert(t != NULL, "invariant"); |
|
81 const u1* const current_top = _mode == concurrent ? t->concurrent_top() : t->top(); |
|
82 const size_t unflushed_size = t->pos() - current_top; |
|
83 if (unflushed_size == 0) { |
|
84 if (_mode == concurrent) { |
|
85 t->set_concurrent_top(current_top); |
|
86 } |
|
87 return true; |
|
88 } |
|
89 const bool result = _operation.discard(t, current_top, unflushed_size); |
|
90 if (_mode == concurrent) { |
|
91 t->set_concurrent_top(current_top + unflushed_size); |
|
92 } else { |
|
93 t->set_top(current_top + unflushed_size); |
|
94 } |
|
95 return result; |
|
96 } |
|
97 |
|
98 #endif // SHARE_VM_JFR_RECORDER_STORAGE_JFRSTORAGEUTILS_INLINE_HPP |