summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-04-20 15:00:19 -0400
committerEliot Horowitz <eliot@10gen.com>2011-04-21 14:57:44 -0400
commitb291d96b0a536a5832bb89fb08d209128d5d5c97 (patch)
tree145cabc552d4476a1b5b72161fa90388b0152f57 /scripting
parent76d3ea758e0faa4e161c7e4bf677aa94d88cc880 (diff)
downloadmongo-b291d96b0a536a5832bb89fb08d209128d5d5c97.tar.gz
move sleep into core utils instead of shell
Diffstat (limited to 'scripting')
-rw-r--r--scripting/utils.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripting/utils.cpp b/scripting/utils.cpp
index 97eea103bc2..e4924440312 100644
--- a/scripting/utils.cpp
+++ b/scripting/utils.cpp
@@ -46,6 +46,20 @@ namespace mongo {
}
+ BSONObj JSSleep(const mongo::BSONObj &args) {
+ assert( args.nFields() == 1 );
+ assert( args.firstElement().isNumber() );
+ int ms = int( args.firstElement().number() );
+ {
+ auto_ptr< ScriptEngine::Unlocker > u = globalScriptEngine->newThreadUnlocker();
+ sleepmillis( ms );
+ }
+
+ BSONObjBuilder b;
+ b.appendUndefined( "" );
+ return b.obj();
+ }
+
// ---------------------------------
// ---- installer --------
// ---------------------------------
@@ -53,6 +67,7 @@ namespace mongo {
void installGlobalUtils( Scope& scope ) {
scope.injectNative( "hex_md5" , jsmd5 );
scope.injectNative( "version" , JSVersion );
+ scope.injectNative( "sleep" , JSSleep );
installBenchmarkSystem( scope );
}