Y
yatko
Hi,
I want to allocate an array of interprocess_semaphore object
initialized with 0 counter value. This class is a part of boost
library used for thread synchronization.
class interprocess_semaphore {
public:
// construct/copy/destruct
interprocess_semaphore(int);
~interprocess_semaphore();
// public member functions
void post() ;
void wait() ;
bool try_wait() ;
bool timed_wait(const boost:osix_time:time &) ;
};
---
interprocess_semaphore* ready_sem;
ready_sem = new interprocess_semaphore[maxFloor;
Since the class has no default constructor, the compiler gives error.
When I try to use vector, I solve the initialization problem. But at
this time, there is another roblem related with copying semaphores.
vector<interprocess_semaphore> ready_sem;
ready_sem.reserve(maxFloor);
for (int i = 0;i < maxFloor; ++i)
ready_sem.push_back(* new boost::interprocess::interprocess_semaphore
(0));
All I want to do is allocating an array of semephore objects with 0
initial counter value. How can I do that in C++ ?
yatko
I want to allocate an array of interprocess_semaphore object
initialized with 0 counter value. This class is a part of boost
library used for thread synchronization.
class interprocess_semaphore {
public:
// construct/copy/destruct
interprocess_semaphore(int);
~interprocess_semaphore();
// public member functions
void post() ;
void wait() ;
bool try_wait() ;
bool timed_wait(const boost:osix_time:time &) ;
};
---
interprocess_semaphore* ready_sem;
ready_sem = new interprocess_semaphore[maxFloor;
Since the class has no default constructor, the compiler gives error.
When I try to use vector, I solve the initialization problem. But at
this time, there is another roblem related with copying semaphores.
vector<interprocess_semaphore> ready_sem;
ready_sem.reserve(maxFloor);
for (int i = 0;i < maxFloor; ++i)
ready_sem.push_back(* new boost::interprocess::interprocess_semaphore
(0));
All I want to do is allocating an array of semephore objects with 0
initial counter value. How can I do that in C++ ?
yatko