Esempio n. 1
0
int main(int argc, char** argv)
{
//	typedef		int				value_type;
//	typedef const value_type*	const_pointer;
//	typedef const value_type&	const_reference;
//	typedef	const value_type*	const_iterator;	
//
//	//CTimeManager* pTime = CTimeManager::CreateInst();
//	//CPerformance* pPerformance = CPerformance::CreateInst();
//
//	//srand(time(NULL));
//
//	//PERFOR_TIMER_BEFORE(vector);
//	//std::vector<int> tvec;
//	//const int nCountMax = 10000;
//	//for (int i = 0; i < nCountMax; ++ i)
//	//{
//	//	int nRand= rand();
//	//	tvec.push_back(nRand);
//	//}
//
//	//for (int i = 0; i < nCountMax; ++ i)
//	//{
//	//	int nRand= rand();
//	//	for (int j = 0; j < tvec.size(); ++ j)
//	//	{
//	//		if (nRand == tvec[j])
//	//		{
//	//			break;
//	//		}
//	//	}
//	//}
//	//PERFOR_TIMER_AFTER(vector);
//
//	//PERFOR_TIMER_BEFORE(hash_map);
//	//stdext::hash_map<int, int> tMap;
//	//for (int i = 0; i < nCountMax; ++ i)
//	//{
//	//	int nRand= rand();
//	//	tMap[nRand] = i;
//	//}
//
//	//for (int i = 0; i < nCountMax; ++ i)
//	//{
//	//	int nRand= rand();
//	//	int j = tMap[nRand];
//	//}
//	//PERFOR_TIMER_AFTER(hash_map);
//	//CPerformance::Inst()->PrintResult();
//	//CTimeManager::DestroyInst();
//	//CPerformance::DestroyInst();
//	//int nMax = rand()%7;
//
//	//bool bPerNodePod = std::is_pod<CPerforNode>::value;
//	//bool bTestPod = std::is_pod<CTestPod>::value;
//	//logdebugfunc();
//	//filedebugfunc();
//	//timedebugfunc();
//	//i18ndebugfunc();
//	//std::vector<int> dd;
//	//dd.push_back(1);
//	//dd.push_back(2);
//	//dd.push_back(3);
//	//for (auto &i:dd)
//	//{
//	//	Print("%d\n", i);
//	//}
//
//	//testBitSet();
//	//testtypetrait();
//
//	testarray();
//	testList();
//	testSlist();
//	std::vector<int> arr;
//	arr.assign(3,3);
//
//	std::list<int> list(3,0);
//	int size = sizeof(CSizeA);
//	int size2 = sizeof(CSizeB);
//
//	testHashMap();
//	testVector();
//	testCriticalSection();

	CLogManager* pLogManger = CLogManager::CreateInst();
	CLog mProDebugLog;
	CLogManager::Inst()->AddDebugLog(&mProDebugLog, "pro");
	
	
	CStdDisplayer tProPlayer;
	mProDebugLog.AddDisplayer(&tProPlayer);
	
	const char* pProLogName = "pro.log";
	CRollFileDisplayer tProFileDisplayer(const_cast<char*>(pProLogName), 1024000, 10);
	mProDebugLog.AddDisplayer(&tProFileDisplayer);
	
	LOG_DEBUG("pro", "%s", "Pro log message is here!\n");


	Myth::CThreadPool threadpool(4);
	CJob tJob1;
	tJob1.mNum = 1;
	threadpool.pushBackJob(&tJob1);

	CJob tJob2;
	tJob2.mNum = 2;
	threadpool.pushBackJob(&tJob2);

	CJob tJob3;
	tJob3.mNum = 3;
	threadpool.pushBackJob(&tJob3);

	CJob tJob4;
	tJob4.mNum = 4;
	threadpool.pushBackJob(&tJob4);

	CJob tJob5;
	tJob5.mNum = 5;
	threadpool.pushBackJob(&tJob5);

	CJob tJob6;
	tJob6.mNum = 6;
	threadpool.pushBackJob(&tJob6);

	int i = 0;
	while (true)
	{
		//printf("begin next\n");
		cs.lock();
		LOG_DEBUG("pro", "begin next\n");
		cs.unlock();
		threadpool.run();
#ifdef MYTH_OS_WINDOWS
		Sleep(100);
#else
		struct timespec tv;
		tv.tv_sec = 5;
		tv.tv_nsec = 0;

		nanosleep(&tv, NULL);
#endif
		++i;
		if (i > 50)
		{
			break;
		}
	}

	CLogManager::DestroyInst();
}