91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 11KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-02
  • 語言: C/C++
  • 標簽: c++??線程池??

資源簡介

用c++ 實現的線程池工程,可直接使用,其中線程數目可根據空閑情況自增減,并且實現線程跟任務無關聯。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?“threadpoolmanager.h“
#include?
#include?
#include?
#include?
?
?
using?namespace?std;
int?seq?=?0;
int?billNum?=0;
int?inter?=?1;
pthread_mutex_t?m_mutex;
void?myFunc(void*arg)
{
????pthread_mutex_lock(&m_mutex);
????seq++;
????if(seq%inter?==?0?)
????{
????????cout?<????}
????if(seq>=1000000000)
????{
????????cout?<????????seq?=?0;
????????billNum++;
????}
????pthread_mutex_unlock(&m_mutex);
????//sleep();
}
?
int?main(int?argc?char**?argv)
{
????if(argc?!=?6)
????{
????????cout?<????????cout?<????????cout?<????????return?0;
????}
????double?loopSize?=?atof(argv[1]);
????int?taskSize?=?atoi(argv[2]);
????int?threadPoolSize?=?atoi(argv[3]);
????int?preSize?=?atoi(argv[4]);
????inter?=?atoi(argv[5]);
?
????pthread_mutex_init(&m_mutexNULL);
????ThreadPoolManager?manager;
????if(0>manager.Init(taskSize??threadPoolSize?preSize))
????{
????????cout?<????????return?0;
????}
????cout?<????struct?timeval?time_beg?time_end;
????memset(&time_beg?0?sizeof(struct?timeval));
????memset(&time_end?0?sizeof(struct?timeval));?
????gettimeofday(&time_beg?NULL);
????double?i=0;
????for(;?i????{
????????while(0>manager.Run(myFuncNULL))
????????{
????????????usleep(100);
????????}
????}
????gettimeofday(&time_end?NULL);
????long?total?=?(time_end.tv_sec?-?time_beg.tv_sec)*1000000?+?(time_end.tv_usec?-?time_beg.tv_usec);
????cout?<????cout?<????cout?<????//pthread_mutex_destroy(&m_mutex);
????return?0;
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????.......???????440??2018-12-20?14:48??threadpool\commondef.h

????.......??????2143??2018-12-20?14:51??threadpool\main.cpp

????.......???????468??2018-12-20?16:26??threadpool\Makefile

????.......??????4670??2018-12-20?14:48??threadpool\taskpool.cpp

????.......??????2569??2018-12-20?14:49??threadpool\taskpool.h

????.......??????7999??2018-12-20?14:53??threadpool\threadpool.cpp

????.......??????3085??2018-12-20?14:50??threadpool\threadpool.h

????.......??????4111??2018-12-20?14:50??threadpool\threadpoolmanager.cpp

????.......??????3528??2018-12-20?14:51??threadpool\threadpoolmanager.h

?????目錄??????????0??2018-12-20?16:59??threadpool

-----------?---------??----------?-----??----

????????????????29013????????????????????10


評論

共有 條評論