上一页 1 ··· 6 7 8 9 10 11 下一页
摘要: boost::asio实例中的HTTP Server 4使用“stackless coroutines”实现,还从来没见过这种诡异又极其难读的代码,遂到网上八了一下,原来coroutines是一个古老的计算模式,中文翻译叫“协程”,在现代程序语言里面属于“非主流”,erlang语言就是采用的这种模式。coroutine和sub... 阅读全文
posted @ 2010-11-02 16:31 edwardlost 阅读(9403) 评论(4) 推荐(0) 编辑
摘要: 在这几个函数里其实都是调用了do_one这个函数,而这个函数的作用就是从获取完成端口状态,所有定时器以及网络事件都是通过do_one来调度的,do_one的函数原型:它的第一个参数说明了是否阻塞,在do_one代码中:可以看到如果为false,将等待时间为0(即不阻塞)。而run,run_one,及poll,poll_one的实现也相当简单,如下:可以看到run其实就是一直循环执行do_one,并... 阅读全文
posted @ 2010-10-28 18:00 edwardlost 阅读(4076) 评论(0) 推荐(0) 编辑
摘要: 今天仔细看了asio的性能测试项目:Linux Performance Improvements,自己也动手实践了一下,不过测试的不是asio本身不同实现机制的性能(这个比较麻烦,需要下载多个asio的实现版本),只是简单测试了一下asio example中四个不同io_service模型的HTTP Server的性能,看看谁是牛b。测试环境linux服务器,CPU有4个processor,详细配... 阅读全文
posted @ 2010-10-25 14:32 edwardlost 阅读(7436) 评论(0) 推荐(0) 编辑
摘要: 转载:http://www.blogkid.net/archives/2670.html我的Linode十分繁忙,在跑一些密集操作数据库的Rake任务时尤其如此。但我观察发现,Linode服务器的4核CPU,只有第1个核心(CPU#0)非常忙,其他都处于idle状态。不了解Linux是如何调度的,但目前显然有优化的余地。除了处理正常任务,CPU#0还需要处理每秒网卡中断。因此,若能将CPU#0分担的任务摊派到其他CPU核心上,可以预见,系统的处理能力将有更大的提升。两个名词SMP (Symmetrical Multi-Processing):指在一个计算机上汇集了一组处理器(多CPU),各CP 阅读全文
posted @ 2010-10-23 13:56 edwardlost 阅读(29847) 评论(0) 推荐(2) 编辑
摘要: 栈上分配内存: alloca()The alloca() function allocates size bytes of space in the stack frame of the caller. This temporary space isautomatically freed when the function that called alloca() returns to its c... 阅读全文
posted @ 2010-10-16 19:34 edwardlost 阅读(463) 评论(0) 推荐(0) 编辑
摘要: deadline_timer类A deadline timer is always in one of two states: "expired" or "not expired". If the wait() or async_wait() function is called on an expired timer, the wait operation will complete immediately.deadline_timer的使用方法:先使用expires_at()或expires_from_now()方法设置到期时间,然后使用async_ 阅读全文
posted @ 2010-10-13 15:56 edwardlost 阅读(2642) 评论(0) 推荐(0) 编辑
摘要: boost::asio::streambuf使用read_until() 和 async_read_until()读取line-based(使用"\r\n"或者其它自定义字符序列作为delimiter)数据时需要boost::asio::streambuf来缓存读取到的数据。下面是boost文档中的read_unitl()示例: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->boost::asio::streambuf 阅读全文
posted @ 2010-10-11 16:12 edwardlost 阅读(10456) 评论(0) 推荐(0) 编辑
摘要: 域名解析 [代码] 客户端连接指定地址[代码]服务端侦听端口[代码] 阅读全文
posted @ 2010-09-28 14:45 edwardlost 阅读(1953) 评论(0) 推荐(0) 编辑
摘要: 今天在测试boost::asio Tutorial中的 Timer.5 - Synchronising handlers in multithreaded programs程序时,发现数据处理始终是在主线程中执行的,为了验证“If you find yourself running into these limitations, an alternative approach is t... 阅读全文
posted @ 2010-09-27 17:26 edwardlost 阅读(1429) 评论(0) 推荐(0) 编辑
摘要: 今天在执行一个PHP程序的时候遇到一个诡异的问题:将数组print_r出来的数据是正确的,但使用foreach遍历数组时,倒数第2条记录的内容被改成了倒数第3条的,把foreach中的其它无关语句删除了也还是同样问题,foreach如下:print_r($users_all);  //数据是正确的foreach ( $users_all as $k = $u ) {//其中一条内容被篡改成了另外一条  printf("%d - %s, tid:%d, uid:%d\n", $k, $u['section'], $u['tid'], $u['uid']);}这个诡异的问题一时让我摸不着头脑,我 阅读全文
posted @ 2010-09-19 18:25 edwardlost 阅读(2945) 评论(3) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 下一页