chromium basethread使用

不会写博客。慢慢学着写吧。将chromium的base模块分离出来,使用thread方式


#include "stdafx.h"
#include<string>
#include "./base/threading/thread.h"
#include "./base/bind.h"
#include "./base/callback.h"
#include "./base/message_loop/message_loop.h"
#include "./base/at_exit.h"

#pragma  comment(lib,"base.lib")
#pragma  comment(lib,"base_static.lib") 
#pragma  comment(lib,"dynamic_annotations.lib")
#pragma  comment(lib,"DbgHelp.lib")
#pragma  comment(lib,"Psapi.lib")

struct kaka
{
int mmm ;
std::string  mmol;
std::string   mollo;
};
class FilePathWatcherTest 
{
public:
FilePathWatcherTest()
: file_thread_("FilePathWatcherTest1") {
SetUp();
}


virtual ~FilePathWatcherTest() {}
void dosomework(kaka *wo);
bool SetupWatch(kaka &oo_) ;
protected:
virtual void SetUp()  {
// Create a separate file thread in order to test proper thread usage.
base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0);
file_thread_.StartWithOptions(options);


}
base::Thread file_thread_;
};

void FilePathWatcherTest::dosomework(kaka *wo)
{
printf("%d",wo->mmm);
printf("donghai \n");

}

bool FilePathWatcherTest::SetupWatch(kaka &oo_) 
{


file_thread_.message_loop()->PostTask(
FROM_HERE,
base::Bind(&FilePathWatcherTest::dosomework, base::Unretained(this), base::Unretained(&oo_))
);
return true;
}
int _tmain(int argc, _TCHAR* argv[])
{
base :: AtExitManager exit_manager;
FilePathWatcherTest pp;
kaka wo[10];
for (int i=0; i <10 ; i++)
{
wo[i].mmm = i;
Sleep(2);
pp.SetupWatch(wo[i]);
}
while (1);
return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值