// thread_safe_signals library // basic test for alternate threading models // Copyright Frank Mori Hess 2008 // Use, modification and // distribution is subject to 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) // For more information, see http://www.boost.org // note boost/test/minimal.hpp can cause windows.h to get included, which // can screw up our checks of _WIN32_WINNT if it is included // after boost/signals2/mutex.hpp. Frank Hess 2009-03-07. #include #include #include // combiner that returns the number of slots invoked struct slot_counter { typedef unsigned result_type; template unsigned operator()(InputIterator first, InputIterator last) const { unsigned count = 0; for (; first != last; ++first) { try { *first; ++count; } catch(const boost::bad_weak_ptr &) {} } return count; } }; void myslot() { } template void simple_test() { signal_type sig; sig.connect(typename signal_type::slot_type(&myslot)); BOOST_CHECK(sig() == 1); sig.disconnect(&myslot); BOOST_CHECK(sig() == 0); } int test_main(int, char*[]) { typedef boost::signals2::signal, boost::function, boost::function, boost::mutex> sig0_mt_type; simple_test(); typedef boost::signals2::signal, boost::function, boost::function, boost::signals2::dummy_mutex> sig0_st_type; simple_test(); return 0; }