summaryrefslogtreecommitdiff
path: root/src/mongo/db/clientcursor.cpp
diff options
context:
space:
mode:
authorLaszlo Boszormenyi (GCS) <gcs@debian.org>2013-10-18 10:31:13 +0200
committerLaszlo Boszormenyi (GCS) <gcs@debian.org>2013-10-18 10:31:13 +0200
commit65585c90b12d6523bea75a2aebaae2a2fdf9e641 (patch)
treeccb3081edfe67f988844af661a2bf93aa95ae09f /src/mongo/db/clientcursor.cpp
parente3904bf97e74cbbe5dde6b3abc3e797ad7d26b5d (diff)
Imported Upstream version 2.4.6upstream/2.4.6
Diffstat (limited to 'src/mongo/db/clientcursor.cpp')
-rw-r--r--src/mongo/db/clientcursor.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index a0693dd8c7d..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();
@@ -564,7 +574,7 @@ namespace mongo {
// need to lock this else rec->touch won't be safe file could disappear
lk.reset( new LockMongoFilesShared() );
}
-
+
dbtempreleasecond unlock;
if ( unlock.unlocked() ) {
if ( haveReadLock ) {
@@ -574,16 +584,26 @@ namespace mongo {
#ifdef _WIN32
SwitchToThread();
#else
- sleepmicros(1);
+ if ( micros == 0 ) {
+ yieldOrSleepFor1Microsecond();
+ }
+ else {
+ sleepmicros(1);
+ }
#endif
}
else {
- if ( micros == -1 )
+ if ( micros == -1 ) {
micros = Client::recommendedYieldMicros();
- if ( micros > 0 )
+ }
+ else if ( micros == 0 ) {
+ yieldOrSleepFor1Microsecond();
+ }
+ else if ( micros > 0 ) {
sleepmicros( micros );
+ }
}
-
+
}
else if ( Listener::getTimeTracker() == 0 ) {
// we aren't running a server, so likely a repair, so don't complain