实现多线程对队列的读写操作(封装类)
source link: https://blogread.cn/it/article/897?f=hot1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
实现多线程对队列的读写操作(封装类)
#include “thread_base.h”
class CChildThread:public CThreadBase
{
protected:
virtual int Process(StructSyncData * oneData,void* args)
{
//printf(”%lld\n”,oneData->ID);
return 0;
}
virtual int init(char* cfgFileName)
{
m_ThreadNum=100;
m_BoolWriteBill=true;
return 0;
}
virtual void AfterAddData(long long popID,int iTime,int preRet)
{
if(preRet)
{
int t_Time=time(NULL);
WriteBill(“[%lld][%d][%d]\n”,popID,iTime,t_Time);
}
}
};
int main()
{
CChildThread t_thread;
int ret;
ret = t_thread.Init(“”);
if(ret)
{
return 0;
}
t_thread.Start();
long long popID=0;
int i=0;
while(1)
{
StructSyncData *t_data = new StructSyncData();
t_data->ID=i;
t_thread.AddData(t_data,popID);
i++;
}
}
希望对大家有用~
觉得文章有用?立即:
和朋友一起 共学习 共进步!
建议继续学习:
扫一扫订阅我的微信号:IT技术博客大学习
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK