|
Boost-Commit : |
From: anthony_at_[hidden]
Date: 2008-03-03 03:44:43
Author: anthonyw
Date: 2008-03-03 03:44:42 EST (Mon, 03 Mar 2008)
New Revision: 43461
URL: http://svn.boost.org/trac/boost/changeset/43461
Log:
Test and fix for issue #1665
Text files modified:
trunk/boost/thread/pthread/tss.hpp | 2
trunk/boost/thread/win32/tss.hpp | 2
trunk/libs/thread/test/test_tss.cpp | 42 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 2 deletions(-)
Modified: trunk/boost/thread/pthread/tss.hpp
==============================================================================
--- trunk/boost/thread/pthread/tss.hpp (original)
+++ trunk/boost/thread/pthread/tss.hpp 2008-03-03 03:44:42 EST (Mon, 03 Mar 2008)
@@ -52,7 +52,7 @@
void operator()(void* data)
{
- cleanup_function(data);
+ cleanup_function(static_cast<T*>(data));
}
};
Modified: trunk/boost/thread/win32/tss.hpp
==============================================================================
--- trunk/boost/thread/win32/tss.hpp (original)
+++ trunk/boost/thread/win32/tss.hpp 2008-03-03 03:44:42 EST (Mon, 03 Mar 2008)
@@ -51,7 +51,7 @@
void operator()(void* data)
{
- cleanup_function(data);
+ cleanup_function(static_cast<T*>(data));
}
};
Modified: trunk/libs/thread/test/test_tss.cpp
==============================================================================
--- trunk/libs/thread/test/test_tss.cpp (original)
+++ trunk/libs/thread/test/test_tss.cpp 2008-03-03 03:44:42 EST (Mon, 03 Mar 2008)
@@ -187,12 +187,54 @@
timed_test(&do_test_tss, 2);
}
+bool tss_cleanup_called=false;
+
+struct Dummy
+{};
+
+void tss_custom_cleanup(Dummy* d)
+{
+ delete d;
+ tss_cleanup_called=true;
+}
+
+boost::thread_specific_ptr<Dummy> tss_with_cleanup(tss_custom_cleanup);
+
+void tss_thread_with_custom_cleanup()
+{
+ tss_with_cleanup.reset(new Dummy);
+}
+
+void do_test_tss_with_custom_cleanup()
+{
+ boost::thread t(tss_thread_with_custom_cleanup);
+ try
+ {
+ t.join();
+ }
+ catch(...)
+ {
+ t.interrupt();
+ t.join();
+ throw;
+ }
+
+ BOOST_CHECK(tss_cleanup_called);
+}
+
+
+void test_tss_with_custom_cleanup()
+{
+ timed_test(&do_test_tss_with_custom_cleanup, 2);
+}
+
boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
{
boost::unit_test_framework::test_suite* test =
BOOST_TEST_SUITE("Boost.Threads: tss test suite");
test->add(BOOST_TEST_CASE(test_tss));
+ test->add(BOOST_TEST_CASE(test_tss_with_custom_cleanup));
return test;
}
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