21 * questions.
22 */
23
24 #ifndef SHARE_GC_Z_ZRELOCATIONSET_INLINE_HPP
25 #define SHARE_GC_Z_ZRELOCATIONSET_INLINE_HPP
26
27 #include "gc/z/zRelocationSet.hpp"
28 #include "runtime/atomic.hpp"
29
30 template <bool parallel>
31 inline ZRelocationSetIteratorImpl<parallel>::ZRelocationSetIteratorImpl(ZRelocationSet* relocation_set) :
32 _relocation_set(relocation_set),
33 _next(0) {}
34
35 template <bool parallel>
36 inline bool ZRelocationSetIteratorImpl<parallel>::next(ZForwarding** forwarding) {
37 const size_t nforwardings = _relocation_set->_nforwardings;
38
39 if (parallel) {
40 if (_next < nforwardings) {
41 const size_t next = Atomic::add(1u, &_next) - 1u;
42 if (next < nforwardings) {
43 *forwarding = _relocation_set->_forwardings[next];
44 return true;
45 }
46 }
47 } else {
48 if (_next < nforwardings) {
49 *forwarding = _relocation_set->_forwardings[_next++];
50 return true;
51 }
52 }
53
54 return false;
55 }
56
57 #endif // SHARE_GC_Z_ZRELOCATIONSET_INLINE_HPP
|
21 * questions.
22 */
23
24 #ifndef SHARE_GC_Z_ZRELOCATIONSET_INLINE_HPP
25 #define SHARE_GC_Z_ZRELOCATIONSET_INLINE_HPP
26
27 #include "gc/z/zRelocationSet.hpp"
28 #include "runtime/atomic.hpp"
29
30 template <bool parallel>
31 inline ZRelocationSetIteratorImpl<parallel>::ZRelocationSetIteratorImpl(ZRelocationSet* relocation_set) :
32 _relocation_set(relocation_set),
33 _next(0) {}
34
35 template <bool parallel>
36 inline bool ZRelocationSetIteratorImpl<parallel>::next(ZForwarding** forwarding) {
37 const size_t nforwardings = _relocation_set->_nforwardings;
38
39 if (parallel) {
40 if (_next < nforwardings) {
41 const size_t next = Atomic::add(&_next, 1u) - 1u;
42 if (next < nforwardings) {
43 *forwarding = _relocation_set->_forwardings[next];
44 return true;
45 }
46 }
47 } else {
48 if (_next < nforwardings) {
49 *forwarding = _relocation_set->_forwardings[_next++];
50 return true;
51 }
52 }
53
54 return false;
55 }
56
57 #endif // SHARE_GC_Z_ZRELOCATIONSET_INLINE_HPP
|