摘要:1 introduction 1.2 Asynchronous by design two most common ways to work with or implement an asynchronous API, 1.2.1 Callbacks 回调函数,本质, move the execution of these methods from the “caller” thr...
阅读全文
摘要:线程安全定义A class is thread-safe if it behaves correctly when accessed from multiple threads, regardless of the scheduling or interleaving of the execution of those threads by the runtime environment, and with no additional synchronization or other coordination on the part of the calling code.A Stateles
阅读全文
摘要:Actors Defining an actor class MyActor extends Actor { def receive = { }} In Scala, the receive block is actually a partial function, which allows the usage of pattern matching syntax....
阅读全文
摘要:参考Akka Essentials 1 Introduction to Akka Actor Model Actor模式的由来 In 1973, Carl Hewitt, Peter Bishop, and Richard Steiger wrote a paper—A Universal Modular ACTOR Formalism for Artificial Intel...
阅读全文
摘要:Scalable IO in Java http://gee.cs.oswego.edu/dl/cpjslides/nio.pdf 大部分IO都是下面这个步骤, Most have same basic structure: Read request Decode request Process service Encode reply Send reply 关...
阅读全文
摘要:Java是非常繁杂的语言, 比如IO就是典型的代表... Java IO 首先1.0, 是基于8位字节流的InputStream和OutputStream系列 然后是1.1, 是基于16位的字符流(unicode)的Reader和Writer系列 下表是对应关系, 其中InputStreamReader和OutputStreamWriter, 起到两个系列之间的适配作用 当然实际的...
阅读全文
摘要:Disruptor 2.0, (http://ifeve.com/disruptor-2-change/) Disruptor为了更便于使用, 在2.0做了比较大的调整, 比较突出的是更换了几乎所有的概念名 老版本, 新版本, 从左到右的变化如下, 1. Producer –> Publisher 2. ProducerBarrier被integrate到Ring...
阅读全文
摘要:http://mechanitis.blogspot.com/search/label/disruptor http://ifeve.com/disruptor/, 并发框架Disruptor译文 http://blog.sina.com.cn/s/blog_68ffc7a4010150yl.html, 论文译文 LMAX需要搭建high performance的交易平台, 所以需要基...
阅读全文
摘要:http://www.eecs.harvard.edu/~mdw/papers/seda-sosp01.pdf, paper Staged Event Driven Architecture (SEDA) 介绍 并发的编程模型 1. 多线程模型 最为传统的模型, 为每个request起个新的thread去执行, 以实现并发 最大的问题是, 扩展问题, request很多的时候...
阅读全文
摘要:http://www.artima.com/articles/io_design_patterns.html http://note.sdo.com/u/1434409594/n/lvRFW~kjR2N0LX0nE004_r http://www.cnblogs.com/xuxm2007/archive/2011/08/15/2139808.html, 图示 我看了些blog, 很少有...
阅读全文
摘要:那我就来继续随便谈谈Twisted 首先讨论一下, 为什么需要twisted, 需要异步 为了更高效的利用CPU和资源, 提高用户的相应速度 任务需要较长时间才能完成分成两种情况, 1) 计算量较大, 需要CPU算好久才能算出来, 自然算出来才能给结果, 称为CPU等待. 2) 需要等待其他的数据, 比如需要从服务器等待获取信息, 需要从数据库等待查询结果, 这种虽然自己很闲, 无事可做...
阅读全文
摘要:Part 11: Your Poetry is Served A Twisted Poetry Server Now that we’ve learned so much about writing clients with Twisted, let’s turn around and re-implement our poetry server with Twisted too. And t...
阅读全文
摘要:Part 6: And Then We Took It Higher Part5中的client2.0, 在封装性上已经做的不错, 用户只需要了解和修改PoetryProtocol, PoetryClientFactory就可以完成一个应用. 其实此处, protocol的逻辑就是接受数据, 接受完以后通知factory处理, 这段逻辑已经可以作为common的框架代码, 用户无需改动. 真正需...
阅读全文
摘要:之前看的时候, 总觉得思路不是很清晰, 其实Dave在这个模型问题上没有说清楚, 参考同步和异步, 阻塞和非阻塞, Reactor和Proactor 对于阻塞一定是同步的, 但是反之不一定, 对于多线程本质上也是阻塞的方式, 只不过是多个线程一起阻塞, 适用于CPU密集型的任务, 因为事情总要人做的, 无论什么模型都不能让做事情的实际时间变少. 对于非阻塞, 节省的是等待的时间, 所以适用于...
阅读全文