// Copyright 2018 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_OBJECTS_SLOTS_ATOMIC_INL_H_ #define V8_OBJECTS_SLOTS_ATOMIC_INL_H_ #include "src/base/atomic-utils.h" #include "src/objects/compressed-slots.h" #include "src/objects/slots.h" namespace v8 { namespace internal { // This class is intended to be used as a wrapper for elements of an array // that is passed in to STL functions such as std::sort. It ensures that // elements accesses are atomic. // Usage example: // FixedArray array; // AtomicSlot start(array->GetFirstElementAddress()); // std::sort(start, start + given_length, // [](Tagged_t a, Tagged_t b) { // // Decompress a and b if necessary. // return my_comparison(a, b); // }); // Note how the comparator operates on Tagged_t values, representing the raw // data found at the given heap location, so you probably want to construct // an Object from it. class AtomicSlot : public SlotBase<AtomicSlot, Tagged_t> { … }; } // namespace internal } // namespace v8 #endif // V8_OBJECTS_SLOTS_ATOMIC_INL_H_