mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Modified examples so that they can be run in parallel.
[SVN r52391]
This commit is contained in:
@@ -24,7 +24,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc == 1){ //Parent process
|
||||
//Create a native windows shared memory object.
|
||||
//<-
|
||||
#if 1
|
||||
windows_shared_memory shm (create_only, test::get_process_id_name(), read_write, 1000);
|
||||
#else
|
||||
//->
|
||||
windows_shared_memory shm (create_only, "MySharedMemory", read_write, 1000);
|
||||
//<-
|
||||
#endif
|
||||
//->
|
||||
|
||||
//Map the whole shared memory in this process
|
||||
mapped_region region(shm, read_write);
|
||||
@@ -33,14 +41,25 @@ int main(int argc, char *argv[])
|
||||
std::memset(region.get_address(), 1, region.get_size());
|
||||
|
||||
//Launch child process
|
||||
std::string s(argv[0]); s += " child";
|
||||
std::string s(argv[0]); s += " child ";
|
||||
//<-
|
||||
s += test::get_process_id_name();
|
||||
//->
|
||||
if(0 != std::system(s.c_str()))
|
||||
return 1;
|
||||
//windows_shared_memory is destroyed when the last attached process dies...
|
||||
}
|
||||
else{
|
||||
//Open already created shared memory object.
|
||||
//<-
|
||||
#if 1
|
||||
windows_shared_memory shm (open_only, test::get_process_id_name(), read_only);
|
||||
#else
|
||||
//->
|
||||
windows_shared_memory shm (open_only, "MySharedMemory", read_only);
|
||||
//<-
|
||||
#endif
|
||||
//->
|
||||
|
||||
//Map the whole shared memory in this process
|
||||
mapped_region region(shm, read_only);
|
||||
|
||||
Reference in New Issue
Block a user