| 1 | // Copyright (C) 2009 Vicente J. Botet Escriba
|
|---|
| 2 | //
|
|---|
| 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|---|
| 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|---|
| 5 | #include <boost/thread/thread.hpp>
|
|---|
| 6 | #include <boost/test/unit_test.hpp>
|
|---|
| 7 | #include <iostream>
|
|---|
| 8 |
|
|---|
| 9 | static bool mycallable1_called =false;
|
|---|
| 10 |
|
|---|
| 11 | static bool mycallable2_called =false;
|
|---|
| 12 |
|
|---|
| 13 | struct mycallable1
|
|---|
| 14 | {
|
|---|
| 15 | void operator()() const {
|
|---|
| 16 | mycallable1_called=true;
|
|---|
| 17 | std::cout << "mycallable1" << std::endl;
|
|---|
| 18 | };
|
|---|
| 19 | };
|
|---|
| 20 |
|
|---|
| 21 | struct mycallable2
|
|---|
| 22 | {
|
|---|
| 23 | void operator()() const {
|
|---|
| 24 | mycallable2_called=true;
|
|---|
| 25 | std::cout << "mycallable2" << std::endl;
|
|---|
| 26 | //BOOST_CHECK(false && "mycallable2 has been called");
|
|---|
| 27 | };
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 | void my_thread() {
|
|---|
| 31 | mycallable1 x;
|
|---|
| 32 | boost::this_thread::at_thread_exit(x);
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | void test_ticket_2739()
|
|---|
| 36 | {
|
|---|
| 37 | mycallable2 x;
|
|---|
| 38 | boost::this_thread::at_thread_exit(x);
|
|---|
| 39 |
|
|---|
| 40 | boost::thread th(my_thread);
|
|---|
| 41 | th.join();
|
|---|
| 42 | BOOST_CHECK(mycallable1_called);
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
|
|---|
| 46 | {
|
|---|
| 47 | boost::unit_test_framework::test_suite* test =
|
|---|
| 48 | BOOST_TEST_SUITE("Boost.Threads: ticket 2739");
|
|---|
| 49 |
|
|---|
| 50 | test->add(BOOST_TEST_CASE(test_ticket_2739));
|
|---|
| 51 | return test;
|
|---|
| 52 | }
|
|---|