00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "../pch.h"
00019
00020 namespace mongo {
00021
00022
00023
00024
00025
00026
00027 class FileAllocator : boost::noncopyable {
00028
00029
00030
00031
00032
00033 public:
00034 void start();
00035
00040 void requestAllocation( const string &name, long &size );
00041
00042
00047 void allocateAsap( const string &name, unsigned long long &size );
00048
00049 void waitUntilFinished() const;
00050
00051 bool hasFailed() const;
00052
00053 static void ensureLength(int fd , long size);
00054
00056 static FileAllocator * get();
00057
00058 private:
00059
00060 FileAllocator();
00061
00062 #if !defined(_WIN32)
00063 void checkFailure();
00064
00065
00066
00067 long prevSize( const string &name ) const;
00068
00069
00070 bool inProgress( const string &name ) const;
00071
00073 static void run( FileAllocator * fa );
00074
00075 mutable mongo::mutex _pendingMutex;
00076 mutable boost::condition _pendingUpdated;
00077
00078 list< string > _pending;
00079 mutable map< string, long > _pendingSize;
00080
00081 bool _failed;
00082 #endif
00083
00084 static FileAllocator* _instance;
00085
00086 };
00087
00089 boost::filesystem::path ensureParentDirCreated(const boost::filesystem::path& p);
00090
00091 }