summaryrefslogtreecommitdiff
path: root/client/parallel.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-11-03 22:53:32 -0500
committerEliot Horowitz <eliot@10gen.com>2009-11-03 22:53:32 -0500
commit974dc89ad514256355a278536a337d573bedd52d (patch)
tree26695da4945f01853166fa45e862ad09601c4b1b /client/parallel.h
parent37baf952b83a24deeb98dc1a1e66adaed4e9a12b (diff)
downloadmongo-974dc89ad514256355a278536a337d573bedd52d.tar.gz
some threaded options for doing queries remotely
Diffstat (limited to 'client/parallel.h')
-rw-r--r--client/parallel.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/client/parallel.h b/client/parallel.h
index a2189c6c745..3129937c193 100644
--- a/client/parallel.h
+++ b/client/parallel.h
@@ -105,4 +105,56 @@ namespace mongo {
BSONObj * _nexts;
};
+
+ class Future {
+ public:
+ class CommandResult {
+ public:
+
+ string getServer() const { return _server; }
+
+ bool isDone() const { return _done; }
+
+ bool ok() const {
+ assert( _done );
+ return _ok;
+ }
+
+ BSONObj result() const {
+ assert( _done );
+ return _res;
+ }
+
+ /**
+ blocks until command is done
+ returns ok()
+ */
+ bool join();
+
+ private:
+
+ CommandResult( const string& server , const string& db , const BSONObj& cmd );
+
+ string _server;
+ string _db;
+ BSONObj _cmd;
+
+ boost::thread _thr;
+
+ BSONObj _res;
+ bool _done;
+ bool _ok;
+
+ friend class Future;
+ };
+
+ static void commandThread();
+
+ static shared_ptr<CommandResult> spawnCommand( const string& server , const string& db , const BSONObj& cmd );
+
+ private:
+ static shared_ptr<CommandResult> * _grab;
+ };
+
+
}