http://stackoverflow.com/questions/2625493/asynchronous-vs-non-blocking

In many circumstances they are different names for the same thing, but in some contexts they are quite different. So it depends. Terminology术语 is not applied in a totally consistent way across the whole software industry.

For example in the classic sockets API, a non-blocking socket is one that simply returns immediately with a special "would block" error message, whereas a blocking socket would have blocked. You have to use a separate function such as select or poll to find out when is a good time to retry.

But asynchronous sockets (as supported by Windows sockets), or the asynchronous IO pattern used in .NET, are more convenient. You call a method to start an operation, and the framework calls you back when it's done. Even here, there are basic differences. Asynchronous Win32 sockets "marshal" their results onto a specific GUI thread by passing Window messages, whereas .NET asynchronous IO is free-threaded (you don't know what thread your callback will be called on).

So they don't always mean the same thing. To distil提炼 the socket example, we could say:

  • Blocking and synchronous mean the same thing: you call the API, it hangs up the thread until it has some kind of answer and returns it to you.
  • Non-blocking means that if an answer can't be returned rapidly, the API returns immediately with an error and does nothing else. So there must be some related way to query whether the API is ready to be called (that is, to simulate a wait in an efficient way, to avoid manual polling in a tight loop).
  • Asynchronous means that the API always returns immediately, having started a "background" effort to fulfil your request, so there must be some related way to obtain the result.

http://stackoverflow.com/questions/7931537/whats-the-difference-between-asynchronous-non-blocking-event-base-architectu/9489547#9489547

Asynchronous Asynchronous literally means not synchronous. Email is asynchronous. You send a mail, you don't expect to get a response NOW. But it is not non-blocking. Essentially本质上 what it means is an architecture where "components" send messages to each other without expecting a response immediately. HTTP requests are synchronous. Send a request and get a response.

Non-Blocking This term is mostly used with IO. What this means is that when you make a system call, it will return immediately with whatever result it has without putting your thread to sleep (with high probability). For example non-blocking read/write calls return with whatever they can do and expect caller to execute the call again. try_lock for example is non-blocking call. It will lock only if lock can be acquired. Usual semantics语义 for systems calls is blocking. read will wait until it has some data and put calling thread to sleep.

Event-base This term comes from libevent. non-blocking read/write calls in themselves are useless because they don't tell you "when" should you call them back (retry).

select/epoll/IOCompletionPort etc are different mechanisms for finding out from OS "when" these calls are expected to return "interesting" data.

libevent and other such libraries provide wrappers over these event monitoring facilities provided by various OSes and give a consistent API to work with which runs across operating systems.

Non-blocking IO goes hand in hand with Event-base.

I think these terms overlap.

For example HTTP protocol is synchronous but HTTP implementation using non-blocking IO can be asynchronous.

Again a non-blocking API call like read/write/try_lock is synchronous (it immediately gives a response) but "data handling" is asynchronous.

asynchronous vs non-blocking的更多相关文章

  1. Why should I avoid blocking the Event Loop and the Worker Pool?

    Don't Block the Event Loop (or the Worker Pool) | Node.js https://nodejs.org/en/docs/guides/dont-blo ...

  2. python之协程与IO操作

    协程 协程,又称微线程,纤程.英文名Coroutine. 协程的概念很早就提出来了,但直到最近几年才在某些语言(如Lua)中得到广泛应用. 子程序,或者称为函数,在所有语言中都是层级调用,比如A调用B ...

  3. Linux下5种IO模型的小结

    概述 接触网络编程,我们时常会与各种与IO相关的概念打交道:同步(Synchronous).异步(ASynchronous).阻塞(blocking)和非阻塞(non-blocking).关于概念的区 ...

  4. Java fundamentals of basic IO

    IO is a problem difficult to handle in various of systems because it  always becomes a bottleneck in ...

  5. 4.如何实现用MTQQ通过服务器实现订阅者和发布者的通讯

    1.本例子意在用moquette服务器来作为消息转发,通过订阅者订阅消息,发布者发布消息,然后发布者的消息可以通过服务器转发给订阅者 服务器例子: https://github.com/andsel/ ...

  6. 微软BI SSIS 2012 ETL 控件与案例精讲面试 200 问(SSIS 面试题,ETL 面试题)

    开篇介绍 本自测与面试题出自 微软BI SSIS 2012 ETL 控件与案例精讲 (http://www.hellobi.com/course/21) 课程,对于学完本课程的每一课时和阅读完相关辅助 ...

  7. 微软BI SSIS 2012 ETL 控件与案例精讲课程学习方式与面试准备详解

    开篇介绍 微软BI SSIS 2012 ETL 控件与案例精讲 (http://www.hellobi.com/course/21) 课程从2014年9月开始准备,到2014年12月在 天善BI学院  ...

  8. (转)Making 1 million requests with python-aiohttp

    转自:https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html Making 1 millio ...

  9. [转] Delphi Socket Architecture

    Delphi Socket Architecture - Felix John COLIBRI. abstract : The architecture of the ScktComp socket  ...

  10. SSIS 自测题-数据流控件类

    说明:以下是自己的理解答案,不是标准的答案,如有不妥烦请指出.         有些题目暂时没有答案,有知道的请留言,互相学习,一起进步. 133.请描述一下 Conditional Split 的使 ...

随机推荐

  1. java 网络编程(三)---TCP的基础级示例

    下面是TCP java网络编程的基础示例: tcp传输:客户端建立过程的思路:1.创建TCP客户端的Socket服务,使用的是socket对象,建议在创建的过程中,就明确了目的地和要连接的主机2.如果 ...

  2. React组件开发

    目录: 属性:props 内联样式 状态记忆 : state 生命周期 访问DOM 表单输入 承接快速入门篇:http://www.cnblogs.com/jasonnode/p/4444504.ht ...

  3. C语言初学者代码中的常见错误与瑕疵(15)

    见:http://www.cpfn.org/bbs/viewtopic.php?f=85&t=5946&sid=0252f08a6d697fbf5a684ec5f6faf1f2 相关链 ...

  4. sql如何将同个字段不同值打印在一行

    group_concat(distinct(img)) group by id通过id分组把img的值打印在一行group_concat()通常和group by一起使用,功能是把某个字段的值打印在一 ...

  5. svn权限控制

    http://blog.csdn.net/clever101/article/details/8159105 [groups] #核心层开发组成员 core_dev = lg,zjc #扩展层开发组成 ...

  6. powershell: 生成随机字符串

    ASCII范围内的 获取6个随机字符(字母和数字) 48到57是数字0-9,powershell的范围操作符是..,和Perl 5的一样, 所以 48..57就是指(48 49 50 51 52 53 ...

  7. 为什么anylase和scenaio中的平均响应时间差别会这么大?

    场景里的响应时间截图如下所示: 结果里的响应时间截图如下所示:

  8. Lucas定理模板

    用于大组合数对p取模的计算. #include <cstdio> #include <iostream> #include <cmath> #include < ...

  9. js 闭包理解

    闭包主要应用于两种情况: 1 函数作为返回值. 2 函数作为参数传递. 第一种举例: function fn(){ var max = 10; return function bar(){ if(x ...

  10. weblogic远程调试

    修改 bin/startWebLogic.cmd 增加红字部分,其中9999是调试监听端口,然后可以连接这个端口进行远程调试 set JAVA_DEBUG=-Xdebug -Xnoagent -Xru ...