|
Boost-Commit : |
From: anthony_at_[hidden]
Date: 2008-03-05 15:47:57
Author: anthonyw
Date: 2008-03-05 15:47:56 EST (Wed, 05 Mar 2008)
New Revision: 43520
URL: http://svn.boost.org/trac/boost/changeset/43520
Log:
Imported changeset 43461 to fix issue #1665
Text files modified:
branches/release/boost/thread/pthread/tss.hpp | 2
branches/release/boost/thread/win32/tss.hpp | 2
branches/release/libs/thread/test/test_tss.cpp | 42 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 2 deletions(-)
Modified: branches/release/boost/thread/pthread/tss.hpp
==============================================================================
--- branches/release/boost/thread/pthread/tss.hpp (original)
+++ branches/release/boost/thread/pthread/tss.hpp 2008-03-05 15:47:56 EST (Wed, 05 Mar 2008)
@@ -52,7 +52,7 @@
void operator()(void* data)
{
- cleanup_function(data);
+ cleanup_function(static_cast<T*>(data));
}
};
Modified: branches/release/boost/thread/win32/tss.hpp
==============================================================================
--- branches/release/boost/thread/win32/tss.hpp (original)
+++ branches/release/boost/thread/win32/tss.hpp 2008-03-05 15:47:56 EST (Wed, 05 Mar 2008)
@@ -51,7 +51,7 @@
void operator()(void* data)
{
- cleanup_function(data);
+ cleanup_function(static_cast<T*>(data));
}
};
Modified: branches/release/libs/thread/test/test_tss.cpp
==============================================================================
--- branches/release/libs/thread/test/test_tss.cpp (original)
+++ branches/release/libs/thread/test/test_tss.cpp 2008-03-05 15:47:56 EST (Wed, 05 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