名前付きセマフォを使用してアクセスを管理し、一部のデータを共有メモリに保持します。
#include <boost/interprocess/sync/named_semaphore.hpp>
struct shared_memory_buffer
{
// Application data
int items[10];
// Synchronization data
boost::interprocess::named_semaphore syncSem;
shared_memory_buffer()
: syncSem(boost::interprocess::open_or_create_t, "testSemaphore", 0) // error
{}
};
ただし、示された行で次のコンパイル時エラーが発生します。
error: expected primary-expression before ‘,’ token
これは私のシステムです:
MacOS X 10.6
i686-apple-darwin10-g ++-4.2.1(GCC)4.2.1(Apple Inc.ビルド5664)
ブースト1.44
ありがとうございました!