Dear Boost Grurus,
First of all let me thank you for the huge effort that people like Mr.
Gaztañaga has made to keep boost interprocess improved. It is a really
time-saver API!
I have a very basic question that, despite the large amount of documentation
I've looked, I haven't clarified yet.
I just want to create a global static variables (i.e. instances) for
managed_shared_memory, message_queue, mutex and condition var.
By now I have my app prototype (CGI) is running fine with auto vars, as
appeared in the several examples:
/main() {
...
boost::interprocess::permissions perm;
perm.set_unrestricted();
managed_shared_memory segment(create_only,"MonitorOEE_SharedMemory", 65536,
0, perm);
...
message_queue mq(create_only, "MonitorOEE_MessageQueue", 256,
sizeof(t_QRequest), perm);
...
named_mutex mutex_waiting(create_only, namedMutex, perm);
...
named_condition cdv_wakeup(create_only, namedConditionVar, perm);
...
}/
All segment, mq, cdv_wakeup live in the context of the main function...
Now I want them to be globally accessible from different functions. But I am
not able to. I just partially succeeded creating global pointers to
managed_shared_memory and message_queue. But when constructing object to the
pointer segmentation faults appear...
///Global Declarations
...
static boost::interprocess::message_queue *mq;
static boost::interprocess::managed_shared_memory *segment;
static boost::interprocess::interprocess_mutex mutex_waiting;
static boost::interprocess::interprocess_condition cdv_wakeup;
...
main() {
..
std::auto_ptr<boost::interprocess::managed_shared_memory>ptr01(new
boost::interprocess::managed_shared_memory(open_only,"MonitorOEE_SharedMemory"));
segment = ptr01.get();
//this seems to work but fails when constructing objects:
IPC_SOAPRequest *pSOAPRequest
=segment->construct<IPC_SOAPRequest>(namedSOAPRequest)();
(the autovar counterpart works seamlessly)
...
std::auto_ptr<boost::interprocess::message_queue>ptr02(new
boost::interprocess::message_queue(open_only,MonitorOEE_MessageQueue"));
mq = ptr02.get();
//Seems to work...(send and receive)
..
//dunno how to instantiate to mutex and cond var global references
I am sure it should be an easier and tidier way. Can you give me just the
first steps to work this out? I've been sleepless a couple of nights.
Eskerrik Asko! (Thanks in the basque language!)
First of all let me thank you for the huge effort that people like Mr.
Gaztañaga has made to keep boost interprocess improved. It is a really
time-saver API!
I have a very basic question that, despite the large amount of documentation
I've looked, I haven't clarified yet.
I just want to create a global static variables (i.e. instances) for
managed_shared_memory, message_queue, mutex and condition var.
By now I have my app prototype (CGI) is running fine with auto vars, as
appeared in the several examples:
/main() {
...
boost::interprocess::permissions perm;
perm.set_unrestricted();
managed_shared_memory segment(create_only,"MonitorOEE_SharedMemory", 65536,
0, perm);
...
message_queue mq(create_only, "MonitorOEE_MessageQueue", 256,
sizeof(t_QRequest), perm);
...
named_mutex mutex_waiting(create_only, namedMutex, perm);
...
named_condition cdv_wakeup(create_only, namedConditionVar, perm);
...
}/
All segment, mq, cdv_wakeup live in the context of the main function...
Now I want them to be globally accessible from different functions. But I am
not able to. I just partially succeeded creating global pointers to
managed_shared_memory and message_queue. But when constructing object to the
pointer segmentation faults appear...
///Global Declarations
...
static boost::interprocess::message_queue *mq;
static boost::interprocess::managed_shared_memory *segment;
static boost::interprocess::interprocess_mutex mutex_waiting;
static boost::interprocess::interprocess_condition cdv_wakeup;
...
main() {
..
std::auto_ptr<boost::interprocess::managed_shared_memory>ptr01(new
boost::interprocess::managed_shared_memory(open_only,"MonitorOEE_SharedMemory"));
segment = ptr01.get();
//this seems to work but fails when constructing objects:
IPC_SOAPRequest *pSOAPRequest
=segment->construct<IPC_SOAPRequest>(namedSOAPRequest)();
(the autovar counterpart works seamlessly)
...
std::auto_ptr<boost::interprocess::message_queue>ptr02(new
boost::interprocess::message_queue(open_only,MonitorOEE_MessageQueue"));
mq = ptr02.get();
//Seems to work...(send and receive)
..
//dunno how to instantiate to mutex and cond var global references
I am sure it should be an easier and tidier way. Can you give me just the
first steps to work this out? I've been sleepless a couple of nights.
Eskerrik Asko! (Thanks in the basque language!)