From 3d00a57b692b7f6eda67b9e5cd11798bd575a138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 12 Mar 2010 13:22:13 +0000 Subject: [PATCH] Interprocess: [@https://svn.boost.org/trac/boost/ticket/3439 #3439], [@https://svn.boost.org/trac/boost/ticket/3846 #3846], [@https://svn.boost.org/trac/boost/ticket/3947 #3947], [@https://svn.boost.org/trac/boost/ticket/3985 #3985]. Intrusive: [@https://svn.boost.org/trac/boost/ticket/3668 #3668], [@https://svn.boost.org/trac/boost/ticket/3339 #3688], [@https://svn.boost.org/trac/boost/ticket/3698 #3698], [@https://svn.boost.org/trac/boost/ticket/3706 #3706], [@https://svn.boost.org/trac/boost/ticket/3721 #3721]. [@https://svn.boost.org/trac/boost/ticket/3729 #3729], [@https://svn.boost.org/trac/boost/ticket/3746 #3746], [@https://svn.boost.org/trac/boost/ticket/3781 #3781], [@https://svn.boost.org/trac/boost/ticket/3829 #3829], [@https://svn.boost.org/trac/boost/ticket/3840 #3840], [@https://svn.boost.org/trac/boost/ticket/3339 #3339], [@https://svn.boost.org/trac/boost/ticket/3419 #3419], [@https://svn.boost.org/trac/boost/ticket/3431 #3431], [SVN r60515] --- proj/vc7ide/intermodule_singleton_test.vcproj | 138 ++++++++++++++++++ test/intermodule_singleton_test.cpp | 93 ++++++++++++ test/movable_int.hpp | 2 +- 3 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 proj/vc7ide/intermodule_singleton_test.vcproj create mode 100644 test/intermodule_singleton_test.cpp diff --git a/proj/vc7ide/intermodule_singleton_test.vcproj b/proj/vc7ide/intermodule_singleton_test.vcproj new file mode 100644 index 0000000..1326a3a --- /dev/null +++ b/proj/vc7ide/intermodule_singleton_test.vcproj @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/intermodule_singleton_test.cpp b/test/intermodule_singleton_test.cpp new file mode 100644 index 0000000..7a7a16e --- /dev/null +++ b/test/intermodule_singleton_test.cpp @@ -0,0 +1,93 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2004-2009. 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 +#include +#include + +using namespace boost::interprocess; + +class MyClass +{ + public: + MyClass() + { + std::cout << "Constructor\n"; + } + + void shout() const + { + std::cout << "Shout\n"; + } + + ~MyClass() + { + std::cout << "Destructor\n"; + } +}; + +class MyDerivedClass + : public MyClass +{}; + +class MyThrowingClass +{ + public: + MyThrowingClass() + { + throw int(0); + } +}; + + + +int main () +{ + bool exception_thrown = false; + bool exception_2_thrown = false; + try{ + detail::intermodule_singleton::get(); + } + catch(int &){ + exception_thrown = true; + //Second try + try{ + detail::intermodule_singleton::get(); + } + catch(interprocess_exception &){ + exception_2_thrown = true; + } + } + + if(!exception_thrown || !exception_2_thrown){ + return 1; + } + + MyClass & mc = detail::intermodule_singleton::get(); + mc.shout(); + detail::intermodule_singleton::get().shout(); + detail::intermodule_singleton::get().shout(); + + //Second try + exception_2_thrown = false; + try{ + detail::intermodule_singleton::get(); + } + catch(interprocess_exception &){ + exception_2_thrown = true; + } + if(!exception_2_thrown){ + return 1; + } + + return 0; +} + +#include + diff --git a/test/movable_int.hpp b/test/movable_int.hpp index 1026bdc..c58a883 100644 --- a/test/movable_int.hpp +++ b/test/movable_int.hpp @@ -79,7 +79,7 @@ std::basic_ostream & operator<< class movable_and_copyable_int { - BOOST_COPYABLE_AND_MOVABLE(movable_and_copyable_int) + BOOST_INTERPROCESS_COPYABLE_AND_MOVABLE(movable_and_copyable_int) public: movable_and_copyable_int()