开发者

Proactor and async write

Boost asio implements proactor design pattern baded on ACE proactor.

I unde开发者_C百科rstand why we need async read. Hovewer, I'm a confused with async write.

  1. Why we need is async write? Is it useful for TCP/UDP connection too (can write to TCP/UDP socket take time)?
  2. Can I mix async read with sync write?


1) Why we need is async write? Is it useful for TCP/UDP connection too (can write to TCP/UDP socket take time)?

Asynchronous write is needed for the very same reasons as asynchronous read. When using synchronous write operations, the calls block until all data has been transmitted. This is not desirable for a number of reasons. Primarily to achieve concurrency without use of explicit threads, this is the basis of the proactor design pattern.

2) Can I mix async read with sync write?

Yes, they can and should be mixed. It would be a very odd design to use asynchronous read operations, yet synchronous write operations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜