Modified examples so that they can be run in parallel.

[SVN r52391]
This commit is contained in:
Ion Gaztañaga
2009-04-14 16:22:10 +00:00
parent 9461ec89cc
commit 6b8ae87209
44 changed files with 718 additions and 395 deletions

View File

@@ -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);