Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64331 - in trunk/libs/interprocess: . proj/vc7ide test
From: igaztanaga_at_[hidden]
Date: 2010-07-25 12:02:43


Author: igaztanaga
Date: 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
New Revision: 64331
URL: http://svn.boost.org/trac/boost/changeset/64331

Log:
Changes for Boost 1.45
Added:
   trunk/libs/interprocess/CMakeLists.txt (contents, props changed)
   trunk/libs/interprocess/module.cmake (contents, props changed)
   trunk/libs/interprocess/proj/vc7ide/robust_emulation_test.vcproj (contents, props changed)
   trunk/libs/interprocess/proj/vc7ide/robust_recursive_emulation_test.vcproj (contents, props changed)
   trunk/libs/interprocess/test/CMakeLists.txt (contents, props changed)
   trunk/libs/interprocess/test/robust_emulation_test.cpp (contents, props changed)
   trunk/libs/interprocess/test/robust_mutex_test.hpp (contents, props changed)
   trunk/libs/interprocess/test/robust_recursive_emulation_test.cpp (contents, props changed)

Added: trunk/libs/interprocess/CMakeLists.txt
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/CMakeLists.txt 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,21 @@
+#----------------------------------------------------------------------------
+# This file was automatically generated from the original CMakeLists.txt file
+# Add a variable to hold the headers for the library
+set (lib_headers
+ interprocess
+)
+
+# Add a library target to the build system
+boost_library_project(
+ interprocess
+ # SRCDIRS
+ TESTDIRS test
+ HEADERS ${lib_headers}
+ # DOCDIRS
+ DESCRIPTION "Shared memory, memory mapped files, process-shared mutexes, condition variables, containers and allocators."
+ MODULARIZED
+ AUTHORS "Ion Gaztanaga <igaztanaga -at- gmail.com>"
+ # MAINTAINERS
+)
+
+

Added: trunk/libs/interprocess/module.cmake
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/module.cmake 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1 @@
+boost_module(interprocess DEPENDS date_time intrusive math)
\ No newline at end of file

Added: trunk/libs/interprocess/proj/vc7ide/robust_emulation_test.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/proj/vc7ide/robust_emulation_test.vcproj 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="robust_emulation_test"
+ ProjectGUID="{58CCE183-4AFE-6092-C4F5-BA0D3A692628}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../Bin/Win32/Debug"
+ IntermediateDirectory="Debug/robust_emulation_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/robust_emulation_test_d.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/robust_emulation_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ FixedBaseAddress="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../Bin/Win32/Release"
+ IntermediateDirectory="Release/robust_emulation_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ RuntimeLibrary="2"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/robust_emulation_test.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4C737CF1-6C7A-A035-4376-A1A2C75F232F}">
+ <File
+ RelativePath="..\..\test\robust_emulation_test.cpp">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Added: trunk/libs/interprocess/proj/vc7ide/robust_recursive_emulation_test.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/proj/vc7ide/robust_recursive_emulation_test.vcproj 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="robust_recursive_emulation_test"
+ ProjectGUID="{58CCE183-4AFE-C4F5-6292-B25062C3A898}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../Bin/Win32/Debug"
+ IntermediateDirectory="Debug/robust_recursive_emulation_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/robust_recursive_emulation_test_d.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/robust_recursive_emulation_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ FixedBaseAddress="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../Bin/Win32/Release"
+ IntermediateDirectory="Release/robust_recursive_emulation_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ RuntimeLibrary="2"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/robust_recursive_emulation_test.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{473AF9C1-6C7A-A035-4376-A3C75F20372F}">
+ <File
+ RelativePath="..\..\test\robust_recursive_emulation_test.cpp">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Added: trunk/libs/interprocess/test/CMakeLists.txt
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/test/CMakeLists.txt 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,8 @@
+boost_additional_test_dependencies(interprocess BOOST_DEPENDS test thread date_time multi_index)
+
+
+file(GLOB INTERPROCESS_TESTS *.cpp)
+foreach(TEST ${INTERPROCESS_TESTS})
+ get_filename_component(TEST ${TEST} NAME_WE)
+ boost_test_run(${TEST} DEPENDS boost_thread MULTI_THREADED)
+endforeach()
\ No newline at end of file

Added: trunk/libs/interprocess/test/robust_emulation_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/test/robust_emulation_test.cpp 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,22 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2010-2010. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include <boost/interprocess/detail/config_begin.hpp>
+#include "robust_mutex_test.hpp"
+#include <boost/interprocess/detail/robust_emulation.hpp>
+#include <boost/interprocess/sync/emulation/mutex.hpp>
+
+int main(int argc, char *argv[])
+{
+ using namespace boost::interprocess;
+ return test::robust_mutex_test
+ < detail::robust_emulation_mutex<detail::emulation_mutex> >(argc, argv);
+}
+
+#include <boost/interprocess/detail/config_end.hpp>

Added: trunk/libs/interprocess/test/robust_mutex_test.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/test/robust_mutex_test.hpp 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,204 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2010-2010. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_TEST_ROBUST_MUTEX_TEST_HEADER
+#define BOOST_INTERPROCESS_TEST_ROBUST_MUTEX_TEST_HEADER
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <iostream>
+#include <cstdlib> //std::system
+#include <boost/interprocess/sync/scoped_lock.hpp>
+#include <boost/interprocess/managed_shared_memory.hpp>
+#include "get_process_id_name.hpp"
+#include "mutex_test_template.hpp"
+#include <iostream>
+
+namespace boost{
+namespace interprocess{
+namespace test{
+
+template<class RobustMutex>
+int robust_mutex_test(int argc, char *argv[])
+{
+ try{
+ if(argc == 1){ //Parent process
+ //First usual mutex tests
+ {
+ // test_all_lock<RobustMutex>();
+// test_all_mutex<true, RobustMutex>();
+ }
+ std::cout << "robust mutex recovery test" << std::endl;
+
+ //Remove shared memory on construction and destruction
+ class shm_remove
+ {
+ public:
+ shm_remove(){ shared_memory_object::remove
+ (::boost::interprocess::test::get_process_id_name()); }
+ ~shm_remove(){ shared_memory_object::remove
+ (::boost::interprocess::test::get_process_id_name()); }
+ } remover;
+
+ //Construct managed shared memory
+ managed_shared_memory segment(create_only, get_process_id_name(), 65536);
+
+ //Create two robust mutexes
+ RobustMutex *instance = segment.construct<RobustMutex>
+ ("robust mutex")[2]();
+
+ //Create a flag to notify that both mutexes are
+ //locked and the owner is going to die soon.
+ bool *go_ahead = segment.construct<bool> ("go ahead")(false);
+
+ //Launch child process
+ std::string s(argv[0]); s += " child ";
+ s += get_process_id_name();
+ std::cout << "... launching child" << std::endl;
+ if(0 != std::system(s.c_str()))
+ return 1;
+
+ //Wait until child locks the mutexes and dies
+ while(!*go_ahead){
+ detail::thread_yield();
+ }
+
+ std::cout << "... recovering mutex[0]" << std::endl;
+ //First try to recover lock[0], put into consistent
+ //state and relock it again
+ {
+ //Done, now try to lock it to see if robust
+ //mutex recovery works
+ instance[0].lock();
+ if(!instance[0].previous_owner_dead())
+ return 1;
+ instance[0].consistent();
+ instance[0].unlock();
+ //Since it's consistent, locking is possible again
+ instance[0].lock();
+ instance[0].unlock();
+ }
+ //Now with lock[1], but dont' put it in consistent state
+ //so the mutex is no longer usable
+ std::cout << "... recovering mutex[1]" << std::endl;
+ {
+ //Done, now try to lock it to see if robust
+ //mutex recovery works
+ instance[1].lock();
+ if(!instance[1].previous_owner_dead())
+ return 1;
+ //Unlock a recovered mutex without putting it into
+ //into consistent state marks mutex as unusable.
+ instance[1].unlock();
+ //Since it's NOT consistent, locking is NOT possible again
+ bool exception_thrown = false;
+ try{
+ instance[1].lock();
+ }
+ catch(interprocess_exception &){
+ exception_thrown = true;
+ }
+ if(!exception_thrown){
+ return 1;
+ }
+ }
+ //Now with lock[2], this was locked by child but not
+ //unlocked
+ std::cout << "... recovering mutex[2]" << std::endl;
+ {
+ //Done, now try to lock it to see if robust
+ //mutex recovery works
+ instance[2].lock();
+ if(!instance[2].previous_owner_dead())
+ return 1;
+ //Unlock a recovered mutex without putting it into
+ //into consistent state marks mutex as unusable.
+ instance[2].unlock();
+ //Since it's NOT consistent, locking is NOT possible again
+ bool exception_thrown = false;
+ try{
+ instance[2].lock();
+ }
+ catch(interprocess_exception &){
+ exception_thrown = true;
+ }
+ if(!exception_thrown){
+ return 1;
+ }
+ }
+ }
+ else{
+ //Open managed shared memory
+ managed_shared_memory segment(open_only, argv[2]);
+ //Find mutexes
+ RobustMutex *instance = segment.find<RobustMutex>("robust mutex").first;
+ assert(instance);
+ if(std::string(argv[1]) == std::string("child")){
+ std::cout << "launched child" << std::endl;
+ //Find flag
+ bool *go_ahead = segment.find<bool>("go ahead").first;
+ assert(go_ahead);
+ //Lock, flag and die
+ bool try_lock_res = instance[0].try_lock() && instance[1].try_lock();
+ assert(try_lock_res);
+ if(!try_lock_res)
+ return 1;
+
+ bool *go_ahead2 = segment.construct<bool>("go ahead2")(false);
+ assert(go_ahead2);
+ //Launch grandchild
+ std::string s(argv[0]); s += " grandchild ";
+ s += argv[2];
+ std::cout << "... launching grandchild" << std::endl;
+ if(0 != std::system(s.c_str())){
+ std::cout << "launched terminated with error" << std::endl;
+ return 1;
+ }
+
+ //Wait until child locks the 2nd mutex and dies
+ while(!*go_ahead2){
+ detail::thread_yield();
+ }
+
+ //Done, now try to lock number 3 to see if robust
+ //mutex recovery works
+ instance[2].lock();
+ if(!instance[2].previous_owner_dead()){
+ return 1;
+ }
+ *go_ahead = true;
+ }
+ else{
+ std::cout << "launched grandchild" << std::endl;
+ //grandchild locks the lock and dies
+ bool *go_ahead2 = segment.find<bool>("go ahead2").first;
+ assert(go_ahead2);
+ //Lock, flag and die
+ bool try_lock_res = instance[2].try_lock();
+ assert(try_lock_res);
+ if(!try_lock_res){
+ return 1;
+ }
+ *go_ahead2 = true;
+ }
+ }
+ }catch(...){
+ std::cout << "Exception thrown error!" << std::endl;
+ throw;
+ }
+ return 0;
+}
+
+} //namespace test{
+} //namespace interprocess{
+} //namespace boost{
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif //BOOST_INTERPROCESS_TEST_ROBUST_EMULATION_TEST_HEADER

Added: trunk/libs/interprocess/test/robust_recursive_emulation_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/test/robust_recursive_emulation_test.cpp 2010-07-25 12:02:42 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,23 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2010-2010. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include <boost/interprocess/detail/config_begin.hpp>
+#include "robust_mutex_test.hpp"
+#include <boost/interprocess/detail/robust_emulation.hpp>
+#include <boost/interprocess/sync/emulation/recursive_mutex.hpp>
+
+int main(int argc, char *argv[])
+{
+ using namespace boost::interprocess;
+
+ return test::robust_mutex_test
+ < detail::robust_emulation_mutex<detail::emulation_recursive_mutex> >(argc, argv);
+}
+
+#include <boost/interprocess/detail/config_end.hpp>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk