本文介绍了使用std ::互斥体通过提升管理的线程池:: ASIO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知何故这个问题。我只是想知道,如果它是确定在由的boost :: ASIO handeled功能使用的std ::互斥:io_service对象?股用法somwhat不现实的。从我在我会说这是确定的。因为它指出

Somehow a followup of this question. I am only wondering if it is ok to use a std::mutex in functions handeled by a boost::asio:io_service? Usage of strands is somwhat unpractical. From what I found in the boost reference I would say it is ok. Since it states that

异步完成处理程序将只从当前调用io_service对象线程调用::的run()。

所以其他线程不应该干涉。难道我得到它的权利?

So other threads created by boost should not interfere. Did I get it right?

推荐答案

是的,通过处理器内部的的std ::互斥是完全没有问题。 A 仅仅是一个变相的互斥毕竟队列。

Yes, using a std::mutex inside of a handler is perfectly fine. A strand is just a queue with a mutex in disguise after all.

这篇关于使用std ::互斥体通过提升管理的线程池:: ASIO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 19:44