【发布时间】:2015-06-23 14:12:50
【问题描述】:
我有使用 Windows 信号量 API(CreateSemaphore 等)的旧应用程序,并且正在编写一个新的多平台应用程序,其中我正在使用 Boost 库。
使用 Windows 中的默认 Boost 构建,它会在文件系统中创建 named_semaphore。
文件 \boost\interprocess\detail\workaround.hpp 似乎定义了我希望实现这一点的标志(通过定义 WIN32 并注释掉 #define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION)
这是该文件的摘录:
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#define BOOST_INTERPROCESS_WINDOWS
// #define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
//Define this to connect with shared memory created with versions < 1.54
//#define BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME
#else
但是,单步执行用于创建此信号量的 Boost 代码(使用上述定义)表明它仍会尝试在默认共享目录中创建文件,这会在 Boost 尝试锁定它时导致异常。
有没有人知道这是否可以使用 Boost(现在?)
非常感谢,凯文
【问题讨论】: