mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
intermodule_singleton fixes for many platforms:
- Use Boost.Container to allow debug-release mixed code (in some platforms, std:: containers' ABI changes from Debug to Release) - By default non-Phoenix and Lazy singletons. - Use atexit instead of the global object destructor to obtain LIFO semantics. - Avoid testing Phoenix singletons, as in many plataforms calling atexit from atexit is not supported.
This commit is contained in:
@@ -47,20 +47,20 @@ class MyThrowingClass
|
||||
};
|
||||
|
||||
|
||||
template < template<class T, bool LazyInit = false, bool Phoenix = true> class IntermoduleType >
|
||||
template < template<class T, bool LazyInit, bool Phoenix> class IntermoduleType >
|
||||
int intermodule_singleton_test()
|
||||
{
|
||||
bool exception_thrown = false;
|
||||
bool exception_2_thrown = false;
|
||||
|
||||
try{
|
||||
IntermoduleType<MyThrowingClass, true>::get();
|
||||
IntermoduleType<MyThrowingClass, true, false>::get();
|
||||
}
|
||||
catch(int &){
|
||||
exception_thrown = true;
|
||||
//Second try
|
||||
try{
|
||||
IntermoduleType<MyThrowingClass, true>::get();
|
||||
IntermoduleType<MyThrowingClass, true, false>::get();
|
||||
}
|
||||
catch(interprocess_exception &){
|
||||
exception_2_thrown = true;
|
||||
@@ -71,15 +71,15 @@ int intermodule_singleton_test()
|
||||
return 1;
|
||||
}
|
||||
|
||||
MyClass & mc = IntermoduleType<MyClass>::get();
|
||||
MyClass & mc = IntermoduleType<MyClass, true, false>::get();
|
||||
mc.shout();
|
||||
IntermoduleType<MyClass>::get().shout();
|
||||
IntermoduleType<MyDerivedClass>::get().shout();
|
||||
IntermoduleType<MyClass, true, false>::get().shout();
|
||||
IntermoduleType<MyDerivedClass, true, false>::get().shout();
|
||||
|
||||
//Second try
|
||||
exception_2_thrown = false;
|
||||
try{
|
||||
IntermoduleType<MyThrowingClass, true>::get();
|
||||
IntermoduleType<MyThrowingClass, true, false>::get();
|
||||
}
|
||||
catch(interprocess_exception &){
|
||||
exception_2_thrown = true;
|
||||
@@ -222,7 +222,7 @@ class LogDeadReferenceUser
|
||||
}
|
||||
};
|
||||
|
||||
template < template<class T, bool LazyInit = false, bool Phoenix = true> class IntermoduleType >
|
||||
template < template<class T, bool LazyInit, bool Phoenix> class IntermoduleType >
|
||||
int phoenix_singleton_test()
|
||||
{
|
||||
typedef int DummyType;
|
||||
@@ -254,7 +254,7 @@ int phoenix_singleton_test()
|
||||
return 0;
|
||||
}
|
||||
|
||||
template < template<class T, bool LazyInit = false, bool Phoenix = true> class IntermoduleType >
|
||||
template < template<class T, bool LazyInit, bool Phoenix> class IntermoduleType >
|
||||
int dead_reference_singleton_test()
|
||||
{
|
||||
typedef int DummyType;
|
||||
@@ -280,13 +280,13 @@ int dead_reference_singleton_test()
|
||||
}
|
||||
|
||||
//reduce name length
|
||||
template<typename C, bool LazyInit = true, bool Phoenix = true>
|
||||
template<typename C, bool LazyInit, bool Phoenix>
|
||||
class port_singleton
|
||||
: public ipcdetail::portable_intermodule_singleton<C, LazyInit, Phoenix>
|
||||
{};
|
||||
|
||||
#ifdef BOOST_INTERPROCESS_WINDOWS
|
||||
template<typename C, bool LazyInit = true, bool Phoenix = true>
|
||||
template<typename C, bool LazyInit, bool Phoenix>
|
||||
class win_singleton
|
||||
: public ipcdetail::windows_intermodule_singleton< C, LazyInit, Phoenix>
|
||||
{};
|
||||
@@ -304,12 +304,15 @@ int main ()
|
||||
}
|
||||
#endif
|
||||
|
||||
//Only few platforms support this
|
||||
#ifdef BOOST_INTERPROCESS_ATEXIT_CALLABLE_FROM_ATEXIT
|
||||
//Phoenix singletons are tested after main ends,
|
||||
//LogPhoenixTester does the work
|
||||
phoenix_singleton_test<port_singleton>();
|
||||
#ifdef BOOST_INTERPROCESS_WINDOWS
|
||||
phoenix_singleton_test<win_singleton>();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Dead reference singletons are tested after main ends,
|
||||
//LogDeadReferenceUser does the work
|
||||
@@ -322,4 +325,3 @@ int main ()
|
||||
}
|
||||
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user