00001 00017 /* background.h 00018 00019 Concurrency coordination for administrative operations. 00020 */ 00021 00022 #pragma once 00023 00024 namespace mongo { 00025 00026 /* these are administrative operations / jobs 00027 for a namespace running in the background, and that only one 00028 at a time per namespace is permitted, and that if in progress, 00029 you aren't allowed to do other NamespaceDetails major manipulations 00030 (such as dropping ns or db) even in the foreground and must 00031 instead uassert. 00032 00033 It's assumed this is not for super-high RPS things, so we don't do 00034 anything special in the implementation here to be fast. 00035 */ 00036 class BackgroundOperation : public boost::noncopyable { 00037 public: 00038 static bool inProgForDb(const char *db); 00039 static bool inProgForNs(const char *ns); 00040 static void assertNoBgOpInProgForDb(const char *db); 00041 static void assertNoBgOpInProgForNs(const char *ns); 00042 static void dump(stringstream&); 00043 00044 /* check for in progress before instantiating */ 00045 BackgroundOperation(const char *ns); 00046 00047 virtual ~BackgroundOperation(); 00048 00049 private: 00050 NamespaceString _ns; 00051 static map<string, unsigned> dbsInProg; 00052 static set<string> nsInProg; 00053 }; 00054 00055 } // namespace mongo 00056