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


C++ StateMap::begin方法代码示例

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


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

示例1: destroyState

    /// Destructor.
    ~StateContainer() {
        // Destroy the allocated states.
        for(StateMap::iterator it = _states.begin(); it != _states.end(); ++it) {
            destroyState(it->second);
            it->second = 0;
        }

        // Clear the map.
        _states.clear();
    }
开发者ID:RenatoUtsch,项目名称:boids,代码行数:11,代码来源:StateContainer.hpp

示例2: runMany

        int runMany() {
            StateMap threads;

            {
                string orig = getParam( "host" );
                bool showPorts = false;
                if ( orig == "" )
                    orig = "localhost";

                if ( orig.find( ":" ) != string::npos || hasParam( "port" ) )
                    showPorts = true;

                StringSplitter ss( orig.c_str() , "," );
                while ( ss.more() ) {
                    string host = ss.next();
                    if ( showPorts && host.find( ":" ) == string::npos) {
                        // port supplied, but not for this host.  use default.
                        if ( hasParam( "port" ) )
                            host += ":" + _params["port"].as<string>();
                        else
                            host += ":27017";
                    }
                    _add( threads , host );
                }
            }

            sleepsecs(1);

            int row = 0;
            bool discover = hasParam( "discover" );
            int maxLockedDbWidth = 0;

            while ( 1 ) {
                sleepsecs( (int)ceil(_statUtil.getSeconds()) );

                // collect data
                vector<Row> rows;
                for ( map<string,shared_ptr<ServerState> >::iterator i=threads.begin(); i!=threads.end(); ++i ) {
                    scoped_lock lk( i->second->lock );

                    if ( i->second->error.size() ) {
                        rows.push_back( Row( i->first , i->second->error ) );
                    }
                    else if ( i->second->prev.isEmpty() || i->second->now.isEmpty() ) {
                        rows.push_back( Row( i->first ) );
                    }
                    else {
                        BSONObj out = _statUtil.doRow( i->second->prev , i->second->now );
                        rows.push_back( Row( i->first , out ) );
                    }

                    if ( discover && ! i->second->now.isEmpty() ) {
                        if ( _discover( threads , i->first , i->second ) )
                            break;
                    }
                }

                // compute some stats
                unsigned longestHost = 0;
                BSONObj biggest;
                for ( unsigned i=0; i<rows.size(); i++ ) {
                    if ( rows[i].host.size() > longestHost )
                        longestHost = rows[i].host.size();
                    if ( rows[i].data.nFields() > biggest.nFields() )
                        biggest = rows[i].data;

                    // adjust width up as longer 'locked db' values appear
                    setMaxLockedDbWidth( &rows[i].data, &maxLockedDbWidth ); 
                }

                {
                    // check for any headers not in biggest

                    // TODO: we put any new headers at end,
                    //       ideally we would interleave

                    set<string> seen;

                    BSONObjBuilder b;

                    {
                        // iterate biggest
                        BSONObjIterator i( biggest );
                        while ( i.more() ) {
                            BSONElement e = i.next();
                            seen.insert( e.fieldName() );
                            b.append( e );
                        }
                    }

                    // now do the rest
                    for ( unsigned j=0; j<rows.size(); j++ ) {
                        BSONObjIterator i( rows[j].data );
                        while ( i.more() ) {
                            BSONElement e = i.next();
                            if ( seen.count( e.fieldName() ) )
                                continue;
                            seen.insert( e.fieldName() );
                            b.append( e );
                        }
//.........这里部分代码省略.........
开发者ID:nosqldb,项目名称:mongo,代码行数:101,代码来源:stat.cpp


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