| Index: Source/wtf/SpinLock.h
|
| diff --git a/Source/wtf/testing/WTFTestHelpers.h b/Source/wtf/SpinLock.h
|
| similarity index 74%
|
| copy from Source/wtf/testing/WTFTestHelpers.h
|
| copy to Source/wtf/SpinLock.h
|
| index 7d8bb3193fbac7f0352eb63067326f4c8b9eea8c..ae2f11675f7e006b22994b0de6695d700f2e4dda 100644
|
| --- a/Source/wtf/testing/WTFTestHelpers.h
|
| +++ b/Source/wtf/SpinLock.h
|
| @@ -28,29 +28,32 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef WTFTestHelpers_h
|
| -#define WTFTestHelpers_h
|
| +#ifndef WTF_SpinLock_h
|
| +#define WTF_SpinLock_h
|
|
|
| -#include "wtf/text/CString.h"
|
| -#include "wtf/text/WTFString.h"
|
| +// DESCRIPTION
|
| +// spinLockLock() and spinLockUnlock() are simple spinlock primitives based on
|
| +// the standard CPU primitive of atomic increment and decrement of an int at
|
| +// a given memory address.
|
|
|
| -#include <ostream> // NOLINT
|
| +#include "wtf/Atomics.h"
|
|
|
| namespace WTF {
|
|
|
| -// Output stream operator so gTest's macros work with WebCore strings.
|
| -static std::ostream& operator<<(std::ostream& out, const String& str)
|
| +ALWAYS_INLINE void spinLockLock(int volatile* lock)
|
| {
|
| - return str.isEmpty() ? out : out << str.utf8().data();
|
| + while (atomicIncrement(lock) != 1)
|
| + atomicDecrement(lock);
|
| }
|
|
|
| -// Output stream operator so gtest can print WTF::CString.
|
| -static std::ostream& operator<<(std::ostream& out, const CString& str)
|
| +ALWAYS_INLINE void spinLockUnlock(int volatile* lock)
|
| {
|
| - return out << str.data();
|
| + atomicDecrement(lock);
|
| }
|
|
|
| } // namespace WTF
|
|
|
| +using WTF::spinLockLock;
|
| +using WTF::spinLockUnlock;
|
|
|
| -#endif // WTFTestHelpers_h
|
| +#endif // WTF_PartitionAlloc_h
|
|
|