大龙的博客

常用链接

统计

最新评论

利用此例子可完全明白,完全端口模型

#include "libtorrent/asio.hpp"
#include "boost/bind.hpp"
#include <iostream>

void f()
{
 std::cout << "fwx" << std::endl; 
}

int main(int argc, char * argv)
{
 asio::io_service ser;                  //利用CreateIoCompletionPort创建完全端口
 asio::deadline_timer dea(ser);    //进行句柄关联
 dea.expires_from_now(boost::posix_time::seconds(10));  
 dea.async_wait(boost::bind(f));                                        //这两句相当于一个pair,要push到一个队列当中,创建的线程会来取请求

 ser.run();                                 //利用GetQueuedCompletionStatus函数从完全端口中取已完成的请求

 return 0;
}

posted on 2007-03-08 16:29 大龙 阅读(706) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理