c++ - Can I access boost::interprocess::managed_shared_memory multiple times without opening it again-and-again? -



c++ - Can I access boost::interprocess::managed_shared_memory multiple times without opening it again-and-again? -

i using boost::interprocess::managed_shared_memory create memory shared across processes.

following steps taken:

step

a) create memory.

step

a) open memory. b) write memory

step

a) open memory. b) read memory. c) open memory. d) read memory. e) open memory. f) read memory. g) ...... , on , forth!

now, question is, in step number 3, opening memory again-and-again before reading it! think redundant behavior.

how can read multiple number of times opening once?

actually open command quite expensive in terms of performance, , proving bottleneck in application.

many of samples have managed_shared_memory in main function brevity.

you should, however, create fellow member of relevant class (with responsibility manage lifetime of shared memory mapping).

you of course, maintain local variable in main, you'd forced maintain passing around in function calls. (i not recommend making global variable. or singleton matter).

c++ boost boost-interprocess

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -