Permalink
Browse files

Removed 'thread sleep' when waiting for data to come back from MongoD…

…B, might have minor performance improvement.
  • Loading branch information...
1 parent fbdd05c commit 42c02789bc1ebde32219c41ec9cede4e64e8f4ad @atheken committed Feb 5, 2011
Showing with 2 additions and 10 deletions.
  1. +1 −0 NoRM/Connections/Connection.cs
  2. +1 −10 NoRM/Protocol/Messages/QueryMessageGeneric.cs
@@ -61,6 +61,7 @@ public Connection(ConnectionOptions builder, bool isReadonly)
//if not readonly, or
_client.Connect(builder.PrimaryServer.GetHost(), builder.PrimaryServer.GetPort());
}
+ _client.ReceiveTimeout = builder.QueryTimeout * 1000;
}
/// <summary>
@@ -107,16 +107,7 @@ public ReplyMessage<T> Execute()
_connection.Write(payload2, 0, payload2.Length);
var stream = _connection.GetStream();
- while (!stream.DataAvailable)
- {
- Thread.Sleep(1);
- }
-
- if (!stream.DataAvailable)
- {
- throw new TimeoutException("MongoDB did not return a reply in the specified time for this context: " + _connection.QueryTimeout.ToString());
- }
- return new ReplyMessage<T>(_connection, this._collection, new BinaryReader(new BufferedStream(stream)), MongoOp.Query, this.NumberToTake);
+ return new ReplyMessage<T>(_connection, this._collection, new BinaryReader(new BufferedStream(stream)), MongoOp.Query, this.NumberToTake);
}
/// <summary>

0 comments on commit 42c0278

Please sign in to comment.