BOOST的Thread库博大精深,有很多的多线程概念在里面,今天就对其中很多call都用到的interrupt_wait的实现进行解释。首先,在BOOST文档中,有1个不得不看的概念,如下:
Predefined Interruption Points
The following functions are interruption points, which will throw boost::thread_interrupted if interruption is enabled for the current thread, and interruption is requested for the current thread:
这个是说,有这么多的call可以用interrupt来打断,既有纯打断(属于无所事事,就想打断型)- interruption_point; 又有在休眠等待中被打断(从睡梦中惊醒)- 如其他。下面来看看官方的interrupt的描述

本文详细探讨了BOOST Thread库中的interrupt_wait功能,分析了其内部机制,包括预定义的中断点、成员函数,以及如何通过事件句柄和抛出thread_interrupted异常来实现线程中断。文章还介绍了interrupt原理,展示了thread_data_base结构,阐述了interruptible_wait函数的工作流程,以及中断点interruption_point和interruption_requested的作用。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



