I have legacy applications that use the Windows semaphore API (CreateSemaphore etc.), and am writing a new multiplatform app in which I am using the Boost libraries.
Using a default Boost build in Windows, it creates named_semaphore's in the filesystem.
The file \boost\interprocess\detail\workaround.hpp seems to define flags which I had hoped would achieve this (by defining WIN32
and commenting out #define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION)
Here is an extract from that file:
#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
However, stepping through the Boost code for creating this semaphore (using the defines as above) shows that it still tries to create a file in a default shared directory, and this leads to an exception when Boost tries to lock it.
Does anyone perhaps know if this is possible using Boost (yet?)
Many thanks, Kevin
Windows synchronization lifetime guarantees are not POSIX, which is what Boost Interprocess implements. So, no, it is not possible.