当前位置: 首页>>代码示例>>C++>>正文


C++ MongoMMF::create方法代码示例

本文整理汇总了C++中MongoMMF::create方法的典型用法代码示例。如果您正苦于以下问题:C++ MongoMMF::create方法的具体用法?C++ MongoMMF::create怎么用?C++ MongoMMF::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoMMF的用法示例。


在下文中一共展示了MongoMMF::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: t

 void t() {
     for( int i = 0; i < 20; i++ ) {
         sleepmillis(21);
         string fn = "/tmp/t1";
         MongoMMF f;
         unsigned long long len = 1 * 1024 * 1024;
         assert( f.create(fn, len, /*sequential*/rand()%2==0) );
         {
             char *p = (char *) f.getView();
             assert(p);
             // write something to the private view as a test
             strcpy(p, "hello");
         }
         if( cmdLine.dur ) {
             char *w = (char *) f.view_write();
             strcpy(w + 6, "world");
         }
         MongoFileFinder ff;
         ASSERT( ff.findByPath(fn) );
     }
 }
开发者ID:BendustiK,项目名称:mongo,代码行数:21,代码来源:perftests.cpp

示例2: run

        void run() {

            try { boost::filesystem::remove(fn); }
            catch(...) { }

            writelock lk;

            {
                MongoMMF f;
                unsigned long long len = 256 * 1024 * 1024;
                assert( f.create(fn, len, /*sequential*/false) );
                {
                    char *p = (char *) f.getView();
                    assert(p);
                    // write something to the private view as a test
                    if( cmdLine.dur ) 
                        MemoryMappedFile::makeWritable(p, 6);
                    strcpy(p, "hello");
                }
                if( cmdLine.dur ) {
                    char *w = (char *) f.view_write();
                    strcpy(w + 6, "world");
                }
                MongoFileFinder ff;
                ASSERT( ff.findByPath(fn) );
                ASSERT( ff.findByPath("asdf") == 0 );
            }
            {
                MongoFileFinder ff;
                ASSERT( ff.findByPath(fn) == 0 );
            }

            int N = 10000;
#if !defined(_WIN32) && !defined(__linux__)
            // seems this test is slow on OS X.
            N = 100;
#endif

            // we make a lot here -- if we were leaking, presumably it would fail doing this many.
            Timer t;
            for( int i = 0; i < N; i++ ) {
                MongoMMF f;
                assert( f.open(fn, i%4==1) );
                {
                    char *p = (char *) f.getView();
                    assert(p);
                    if( cmdLine.dur ) 
                        MemoryMappedFile::makeWritable(p, 4);
                    strcpy(p, "zzz");
                }
                if( cmdLine.dur ) {
                    char *w = (char *) f.view_write();
                    if( i % 2 == 0 )
                        ++(*w);
                    assert( w[6] == 'w' );
                }
            }
            if( t.millis() > 10000 ) {
                log() << "warning: MMap LeakTest is unusually slow N:" << N << ' ' << t.millis() << "ms" << endl;
            }

        }
开发者ID:CoolCloud,项目名称:mongo,代码行数:62,代码来源:mmaptests.cpp


注:本文中的MongoMMF::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。