projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Expose move result from LockFreeRingBuffer::Cursor
[folly.git]
/
folly
/
test
/
SpinLockTest.cpp
diff --git
a/folly/test/SpinLockTest.cpp
b/folly/test/SpinLockTest.cpp
index 9f8b279cb82cd3518c9102f1d39ea26aa3c088b4..3be763d633e3f47d21be34dd0f10d242d1a909bb 100644
(file)
--- a/
folly/test/SpinLockTest.cpp
+++ b/
folly/test/SpinLockTest.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
4
Facebook, Inc.
+ * Copyright 201
5
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-37,7
+37,7
@@
void spinlockTestThread(LockedVal<LOCK>* v) {
const int max = 1000;
unsigned int seed = (uintptr_t)pthread_self();
for (int i = 0; i < max; i++) {
const int max = 1000;
unsigned int seed = (uintptr_t)pthread_self();
for (int i = 0; i < max; i++) {
-
asm("pause"
);
+
folly::asm_pause(
);
SpinLockGuardImpl<LOCK> g(v->lock);
int first = v->ar[0];
SpinLockGuardImpl<LOCK> g(v->lock);
int first = v->ar[0];
@@
-60,9
+60,9
@@
struct TryLockState {
};
template <typename LOCK>
};
template <typename LOCK>
-void trylockTestThread(TryLockState<LOCK>* state,
in
t count) {
+void trylockTestThread(TryLockState<LOCK>* state,
size_
t count) {
while (true) {
while (true) {
-
asm("pause"
);
+
folly::asm_pause(
);
SpinLockGuardImpl<LOCK> g(state->lock1);
if (state->obtained >= count) {
break;
SpinLockGuardImpl<LOCK> g(state->lock1);
if (state->obtained >= count) {
break;
@@
-81,7
+81,7
@@
void trylockTestThread(TryLockState<LOCK>* state, int count) {
auto oldFailed = state->failed;
while (state->failed == oldFailed && state->obtained < count) {
state->lock1.unlock();
auto oldFailed = state->failed;
while (state->failed == oldFailed && state->obtained < count) {
state->lock1.unlock();
-
asm("pause"
);
+
folly::asm_pause(
);
state->lock1.lock();
}
state->lock1.lock();
}
@@
-111,7
+111,7
@@
void trylockTest() {
int nthrs = sysconf(_SC_NPROCESSORS_ONLN) + 4;
std::vector<std::thread> threads;
TryLockState<LOCK> state;
int nthrs = sysconf(_SC_NPROCESSORS_ONLN) + 4;
std::vector<std::thread> threads;
TryLockState<LOCK> state;
-
in
t count = 100;
+
size_
t count = 100;
for (int i = 0; i < nthrs; ++i) {
threads.push_back(std::thread(trylockTestThread<LOCK>, &state, count));
}
for (int i = 0; i < nthrs; ++i) {
threads.push_back(std::thread(trylockTestThread<LOCK>, &state, count));
}
@@
-146,7
+146,7
@@
TEST(SpinLock, AppleTryLock) {
}
#endif
}
#endif
-#if
!__ANDROID__
+#if
FOLLY_HAVE_PTHREAD_SPINLOCK_T
TEST(SpinLock, PthreadCorrectness) {
correctnessTest<folly::SpinLockPthreadImpl>();
}
TEST(SpinLock, PthreadCorrectness) {
correctnessTest<folly::SpinLockPthreadImpl>();
}