summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-07-29 15:51:02 -0400
committerDan Pasette <dan@10gen.com>2013-08-01 20:41:58 -0400
commit12ecb7dbc765df9544d21bb3823a5fbde0efe0e6 (patch)
tree125df4051721d3618b3354d56f55c2d0c3080971
parent6d738db1f45ec0f7447e2a14e0216af2410074c8 (diff)
downloadmongo-12ecb7dbc765df9544d21bb3823a5fbde0efe0e6.tar.gz
SERVER-10362: only use pthread_yield on linux, on osx use sleepmicros(1)
-rw-r--r--src/mongo/db/clientcursor.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index aa5452ac4cb..fa39170d73b 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -554,6 +554,16 @@ namespace mongo {
return true;
}
+ void yieldOrSleepFor1Microsecond() {
+#ifdef _WIN32
+ SwitchToThread();
+#elif defined(__linux__)
+ pthread_yield();
+#else
+ sleepmicros(1);
+#endif
+ }
+
void ClientCursor::staticYield( int micros , const StringData& ns , Record * rec ) {
bool haveReadLock = Lock::isReadLocked();
@@ -575,7 +585,7 @@ namespace mongo {
SwitchToThread();
#else
if ( micros == 0 ) {
- pthread_yield();
+ yieldOrSleepFor1Microsecond();
}
else {
sleepmicros(1);
@@ -587,11 +597,7 @@ namespace mongo {
micros = Client::recommendedYieldMicros();
}
else if ( micros == 0 ) {
-#ifdef _WIN32
- SwitchToThread();
-#else
- pthread_yield();
-#endif
+ yieldOrSleepFor1Microsecond();
}
else if ( micros > 0 ) {
sleepmicros( micros );