Skip to content

有关阻塞/同步一节中的说法不准确 #180

Open
@jackyfkc

Description

@jackyfkc

阻塞、非阻塞 一节中,关于阻塞/同步的说法个人认为是不准确的

阻塞 指的是一个函数或者操作本身的特性,比如我们会说 read() 系统调用, BlockingQueue.put() 是阻塞(block) 的,是因为这类函数要在返回之前等某个事情发生或者完成;至于跟调用者, 被调用者有关还是无关,这之间没什么关联

可以参看 Tornado Asynchronous and non-Blocking I/O 一节
A function blocks when it waits for something to happen before returning. A function may block for many reasons: network I/O, disk I/O, mutexes, etc. In fact, every function blocks, at least a little bit, while it is running and using the CPU (for an extreme example that demonstrates why CPU blocking must be taken as seriously as other kinds of blocking, consider password hashing functions like bcrypt, which by design use hundreds of milliseconds of CPU time, far more than a typical network or disk access).

同步 是指调用方要等被调用方完成,不仅仅是描述被调用方的

最后同步和阻塞是二个无关的概念,二者是正交的

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions