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


C++ IOManager类代码示例

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


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

示例1: TEST

//on linux Mordor::IOManager user epoll
TEST(IOManager, event) {
//   Log::root()->level(Log::TRACE);
//   Log::root()->addSink( LogSink::ptr(new StdoutLogSink));
   //IOManager(size_t threads = 1, bool useCaller = true, bool autoStart = true);
   IOManager iomanager;
   const size_t conn_num = 5;
   std::vector<boost::shared_ptr<Conn> > conns; 
   conns.reserve(conn_num);

   //register event
   for(size_t i = 0 ; i < conn_num; i++){
       boost::shared_ptr<Conn> conn(new Conn);
       iomanager.registerEvent(conn->getReadFd(), IOManager::READ,  boost::bind(&Conn::read, conn));
       conns.push_back(conn);
   }

   //write 
   for(size_t i = 0; i < conns.size(); i++) {
      MORDOR_LOG_DEBUG(Log::root()) <<  " write on for  "  << conns[i]->getReadFd();
      conns[i]->write(100);
   }

    iomanager.dispatch();
    iomanager.stop();

   for(size_t i = 0; i < conns.size(); i++) {
      ASSERT_EQ(boost::this_thread::get_id() , conns[i]->tid);
      ASSERT_EQ(100, conns[i]->read_count);
   }
}
开发者ID:trumanz,项目名称:cpp-learning,代码行数:31,代码来源:mordor_iomanager.cpp

示例2: OutputPivot

void PivotCommand :: OutputPivot( IOManager & io ) {

    CSVRow r;
    r.push_back( "" );    // corresponds to row header
    for ( auto col : mCols ) {
        r.push_back( col );
    }
    io.WriteRow( r );

    for( auto row : mRows ) {
        r.clear();
        r.push_back( row );
        for ( auto col : mCols ) {
            ColRow cr( col, row );
            SumCount sc = mColRowValMap[ cr ];
            if ( mAction == Action::Average ) {
                r.push_back( ALib::Str( sc.mSum / sc.mCount ) );
            }
            else {
                r.push_back( ALib::Str( sc.mSum ) );
            }
        }
        io.WriteRow( r );
    }


}
开发者ID:bminossi,项目名称:csvfix,代码行数:27,代码来源:csved_pivot.cpp

示例3: WriteJoinRows

void JoinCommand :: WriteJoinRows( IOManager & io, const CSVRow & row ) {

	string key = MakeKey( row, true );

	MapType::const_iterator pos = mRowMap.lower_bound( key );
	MapType::const_iterator last = mRowMap.upper_bound( key );

	if ( mOuterJoin && pos == last ) {
		io.WriteRow( row );
	}
	else if ( mInvert ) {
		if ( pos == last ) {
			io.WriteRow( row );
		}
		return;
	}
	else {
		while( pos != last ) {
			const CSVRow & jr = pos->second;
			CSVRow newrow = row;
			for ( unsigned int i = 0; i < jr.size(); i++ ) {
				newrow.push_back( jr[i] );
			}
			io.WriteRow( newrow );
			++pos;
		}
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:28,代码来源:csved_join.cpp

示例4: AddVars

void AddVars( ALib::Expression & e, const IOManager & io, const CSVRow & row ) {
	e.ClearPosParams();
	e.AddVar( LINE_VAR, ALib::Str( io.CurrentLine() ));
	e.AddVar( FILE_VAR, ALib::Str( io.CurrentFileName()));
	e.AddVar( FIELD_VAR, ALib::Str( row.size()));
	for ( unsigned int j = 0; j < row.size(); j++ ) {
		e.AddPosParam( row.at( j ) );
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:9,代码来源:csved_evalvars.cpp

示例5: MORDOR_UNITTEST

MORDOR_UNITTEST(IOManager, laterTimer)
{
    int sequence = 0;
    IOManager manager;
    manager.registerTimer(100000, boost::bind(&singleTimer, boost::ref(sequence), 1));
    MORDOR_TEST_ASSERT_EQUAL(sequence, 0);
    manager.dispatch();
    ++sequence;
    MORDOR_TEST_ASSERT_EQUAL(sequence, 2);
}
开发者ID:Abioy,项目名称:mordor,代码行数:10,代码来源:iomanager.cpp

示例6: DoMedian

void SummaryCommand :: DoMedian( IOManager & io ) {

	CSVRow r;

	for ( unsigned int i = 0; i < mFields.size(); i++ ) {
		unsigned int col = mFields[i];
		NumSort ns( col );
		std::sort( mRows.begin(), mRows.end(), ns );
		unsigned int sz = mRows.size();
		double d;
		if ( sz % 2 ) {
			unsigned int idx = (sz / 2);
			d = ALib::ToReal( mRows.at(idx).at(col) );
		}
		else {
			unsigned int idx = (sz / 2) - 1;
			double d1 = ALib::ToReal( mRows.at(idx).at(col) );
			double d2 = ALib::ToReal( mRows.at(idx+1).at(col) );
			d = (d1 + d2) /2;
		}

		r.push_back( ALib::Str( d ) );
	}

	io.WriteRow( r );
}
开发者ID:bminossi,项目名称:csvfix,代码行数:26,代码来源:csved_sum.cpp

示例7: PrintSizes

void SummaryCommand :: PrintSizes( IOManager & io, const SizeMap & sm ) {
	SizeMap::const_iterator it = sm.begin();
	while( it != sm.end() ) {
		io.Out() << it->first + 1 << ": "
				 << it->second.first << "," << it->second.second
				 << "\n";
		++it;
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:9,代码来源:csved_sum.cpp

示例8: DoAvg

void SummaryCommand :: DoAvg( IOManager & io ) {
	vector <double> sums;
	SumCols( sums );
	CSVRow r;
	for ( unsigned int i = 0; i < sums.size(); i++ ) {
		r.push_back( ALib::Str( sums.at(i) / mRows.size() ) );
	}
	io.WriteRow( r );
}
开发者ID:bminossi,项目名称:csvfix,代码行数:9,代码来源:csved_sum.cpp

示例9: Shuffle

void ShuffleCommand :: Shuffle( IOManager & io ) {
    ALib::RandGen rg( mSeed );
    int nout = mCount;
    int last = mRows.size();
    for ( unsigned int i = 0; i < mRows.size() && nout-- > 0; i++ ) {
        int pos = rg.NextInt( 0, last );
        io.WriteRow( mRows[pos] );
        mRows[pos].swap( mRows[--last] );
    }
}
开发者ID:moissinac,项目名称:csvfix,代码行数:10,代码来源:csved_shuffle.cpp

示例10: DoFreq

void SummaryCommand :: DoFreq( IOManager & io ) {
	CalcFreqs();

	for ( unsigned int i = 0; i < mRows.size(); i++ ) {
		string key = MakeKey( mRows.at(i) );
		unsigned int n = mFreqMap.find( key )->second.mFreq;
		CSVRow r = mRows.at(i);
		r.insert( r.begin(), ALib::Str( n ) );
		io.WriteRow( r );
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:11,代码来源:csved_sum.cpp

示例11: WriteRow

void  ReadXMLCommand :: WriteRow( const ALib::XMLElement * r,
										IOManager & io ) {
	CSVRow row;

	for ( unsigned int i = 0; i < r->ChildCount(); i++  ) {
		const ALib::XMLElement * ce = r->ChildElement( i );
		if ( ce && ce->Name() == "td" ) {
			row.push_back( TDToCSV( ce ) );
		}
	}

//	ALib::Dump( std::cout, row );
	io.WriteRow( row );
}
开发者ID:bminossi,项目名称:csvfix,代码行数:14,代码来源:csved_xml.cpp

示例12: DoMode

void SummaryCommand :: DoMode( IOManager & io ) {

	unsigned int mode = CalcFreqs();

	for ( FreqMap::const_iterator it = mFreqMap.begin();
			it != mFreqMap.end(); ++it ) {

		if ( it->second.mFreq == mode ) {
			for ( unsigned int i = 0; i < it->second.mIndex.size(); i++ ) {
				CSVRow r = mRows.at( it->second.mIndex.at(i) );
				r.insert( r.begin(), ALib::Str( mode ) );
				io.WriteRow( r );
			}
		}
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:16,代码来源:csved_sum.cpp

示例13: TableToCSV

void ReadXMLCommand :: TableToCSV( const ALib::XMLElement * e,
										IOManager & io,
										unsigned int idx  ) {

	const ALib::XMLElement * table = FindTable( e );
	if ( table == 0 ) {
		CSVTHROW( "No XML table found in " <<  io.InFileName( idx ) );
	}

	for ( unsigned int i = 0; i < table->ChildCount(); i++ ) {
		const ALib::XMLElement * ce = table->ChildElement( i );
		if ( ce && ce->Name() == "tr" ) {
			WriteRow( ce, io );
		}
	}

}
开发者ID:bminossi,项目名称:csvfix,代码行数:17,代码来源:csved_xml.cpp

示例14: DoMinMax

void SummaryCommand :: DoMinMax( IOManager & io ) {
	CSVRow r = mRows.at(0);

	for ( unsigned int i = 1; i < mRows.size(); i++ ) {
		if ( mType == Min && Cmp( mRows.at(i), r ) < 0 ) {
			r = mRows.at(i);
		}
		else if ( mType == Max && Cmp( mRows.at(i), r ) > 0 ) {
			r = mRows.at(i);
		}
	}

	for ( unsigned int i = 0; i < mRows.size(); i++ ) {
		if ( Cmp( r, mRows.at(i) ) == 0 ) {
			io.WriteRow( mRows.at(i) );
		}
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:18,代码来源:csved_sum.cpp

示例15: privateStore

 //
 //Saves the pair on the disk & memory
 //
 void privateStore(K _key, V _value){
     
     //convert key to char*
     int sizeOfKey = (int)log10(_key) + 2;
     char* keyString = new char[sizeOfKey];
     keyString[sizeOfKey - 1] = '\0';
     sprintf(keyString, "%ld", _key);
     
     
     //place in hashtable
     long index = Hash::stringHash(keyString) % 1000;
     LinkedList<Pair<K, V>>& row = hashTable[index];
     Pair<K,V> pair;
     pair.key = _key;
     pair.value = _value;
     row.addElement(pair);
     IOManager.writeToFile(_key , _value);
     
     delete [] keyString;
 }
开发者ID:emiliev,项目名称:SDP-practicum,代码行数:23,代码来源:HashTable.hpp


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