diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-04-20 15:00:19 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-04-21 14:57:44 -0400 |
commit | b291d96b0a536a5832bb89fb08d209128d5d5c97 (patch) | |
tree | 145cabc552d4476a1b5b72161fa90388b0152f57 /scripting | |
parent | 76d3ea758e0faa4e161c7e4bf677aa94d88cc880 (diff) | |
download | mongo-b291d96b0a536a5832bb89fb08d209128d5d5c97.tar.gz |
move sleep into core utils instead of shell
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/utils.cpp | 15 |
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 ); } |