有什么区别:异步,无阻塞,事件基础架构? [英] What's the difference between: Asynchronous, Non-Blocking, Event-Base architectures?

查看:164
本文介绍了有什么区别:异步,无阻塞,事件基础架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 有什么区别:

  1. What's the difference between:


  • 异步

  • 非阻塞

  • 事件基架构?

  • Asynchronous,
  • Non-Blocking, and
  • Event-base architectures?

能否东西既异步的和的非阻塞的(和基于事件的的)?

Can something be both asynchronous and non-blocking (and event-based)?

什么是编程中最重要的,有东西:异步,无阻塞和/或事件基(或所有3)

What's most important in programming, to have something: asynchronous, non-blocking and/or event-base (or all 3)?

如果你能提供的例子,那将是巨大的。

If you could provide examples, that would be great.

此问题被要求,因为我读这个伟大的计算器上的类似话题的文章但它不回答上面我的问题。

This question is being asked because I was reading this great StackOverflow article on a similar topic but it doesn't answer my questions above.

推荐答案

异步
异步字面​​意思是不同步的。电子邮件是异步的。你发邮件,你不要指望得到回应了。但它不是无阻塞。从本质上讲这是什么意思是一个体系结构,其中组件发送消息给对方没有马上期待的回应。的HTTP请求是同步的。发送请求并得到回应。

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.

非阻塞
该术语主要与IO使用。这意味着,当你做一个系统调用,它会立即与它有什么结果返回没有把你的线程休眠(高概率)。例如非阻塞读/写调用与任何他们可以做,并希望呼叫者再次执行调用返回。 try_lock例如是非阻塞调用。这将仅锁定,如果锁可以收购。对于系统调用常用语义阻止。阅读会等到它有一些数据,并把调用线程睡眠。

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.

事件基
这个词来自libevent的。无阻塞自己的读/写调用无用的,因为他们不告诉你时,你应该叫他们回来(重试)。选择/ epoll的/ IOCompletionPort等都是从OS找出当这些调用有望重返有趣的数据不同的机制。 libevent的等这样的库提供了各种操作系统提供这些事件监控设施,包装和给予一致的API合作与跨操作系统上运行。非阻塞IO齐头并进与事件的基础。

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.

我觉得这些条款重叠。例如HTTP协议是使用非阻塞的IO可以是异步同步但HTTP实现。再次像读/写/ try_lock非阻塞API调用是同步的(它立即进行响应),但数据处理是异步的。

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.

这篇关于有什么区别:异步,无阻塞,事件基础架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆