私は使用してnamed_semaphore
いて、セマフォを宣言してプロセスの数を尋ねたいのですが、現時点では次のようになります。
const unsigned N_CORES = boost::thread::hardware_concurrency();
named_semaphore SEMAPHORE(open_or_create, PROCESS_NAME, N_CORES);
最初に SEMAPHORE を宣言し、別の時点でコア数を取得します。
APIによると:
//!Creates a global semaphore with a name, and an initial count.
//!If the semaphore can't be created throws interprocess_exception
named_semaphore(create_only_t, const char *name, unsigned int initialCount);
//!Opens or creates a global semaphore with a name, and an initial count.
//!If the semaphore is created, this call is equivalent to
//!named_semaphore(create_only_t, ...)
//!If the semaphore is already created, this call is equivalent to
//!named_semaphore(open_only_t, ... )
//!and initialCount is ignored.
named_semaphore(open_or_create_t, const char *name, unsigned int initialCount);
そして私は試しました:
const unsigned N_CORES = boost::thread::hardware_concurrency();
named_semaphore SEMAPHORE(create_only, PROCESS_NAME, N_CORES);
// at other point
SEMAPHORE(open_or_create, PROCESS_NAME, numberOfCores);
しかし、このエラーを表示します:
term does not evaluate to a function taking 3 arguments