Boost学习手册

boost::optional

  1. usage

boost::property_tree

  1. usage

boost::asio

boost::asio::io_service

boost::asio::io_service::post() and boost::asio::io_service::dispatch()

post 优先将任务排进处理队列,然后返回,任务会在某个时机被完成。

dispatch会即时请求io_service去调用指定的任务。

boost::asio::io_context

  1. concept

  2. usage

boost::asio::io_context::strand

  1. concept

类boost::asio::io_context::strand的主要作用是在asio中利用多线程进行事件处理的时候,如果涉及到多线
程访问共享资源,借助于strand类,我们不需要显示的使用线程同步相关的类(比如mutex)就可以让多个事件
处理函数依次执行。

strand定义了事件处理程序的严格顺序调用。
注解描述为:提供串行化的处理调用,strand提供串行执行, 能够保证线程安全, 同时被post或dispatch调用的方法,
不会被并发的执行。

  1. usage

boost::asio::io_context::strand m_strand;
m_strand.dispatch((boost::bind(&Printer::print, this));

boost::asio::io_context::strands m_strand;
m_strand.post(boost::bind(&Printer::print, this));

boost::asio::bind_executor(m_strand, boost::bind(&Printer::print, this)));

boost::posix_time

boost::posix_time::microsec_clock

boost::mutex::scoped_lock

原文地址:https://www.cnblogs.com/xiangleili/p/11347746.html