Boost.Interprocess 提供以下互斥类型:
#include <boost/interprocess/sync/interprocess_mutex.hpp>
Run Code Online (Sandbox Code Playgroud)
interprocess_mutex:非递归、匿名互斥体,可以放置在共享内存或内存映射文件中。
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
Run Code Online (Sandbox Code Playgroud)
interprocess_recursive_mutex:递归、匿名互斥体,可以放置在共享内存或内存映射文件中。
#include <boost/interprocess/sync/named_mutex.hpp>
Run Code Online (Sandbox Code Playgroud)
name_mutex:非递归的命名互斥体。
#include <boost/interprocess/sync/named_recursive_mutex.hpp>
Run Code Online (Sandbox Code Playgroud)
name_recursive_mutex:递归的、命名的互斥体。
我建议使用命名互斥体。查看文档