1 // Copyright (C) 2013 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 6 // <boost/thread/synchronized_value.hpp> 7 8 // class synchronized_value<T,M> 9 10 // strict_lock_ptr<T,M> synchronize(); 11 // const_strict_lock_ptr<T,M> synchronize() const; 12 13 14 #define BOOST_THREAD_VERSION 4 15 16 #include <boost/thread/synchronized_value.hpp> 17 18 #include <boost/detail/lightweight_test.hpp> 19 20 struct S { fS21 int f() const {return 1;} gS22 int g() {return 1;} 23 }; 24 main()25int main() 26 { 27 { 28 boost::synchronized_value<S> v; 29 boost::strict_lock_ptr<S> ptr = v.synchronize(); 30 BOOST_TEST(ptr->f()==1); 31 BOOST_TEST(ptr->g()==1); 32 } 33 { 34 const boost::synchronized_value<S> v; 35 boost::const_strict_lock_ptr<S> ptr = v.synchronize(); 36 BOOST_TEST(ptr->f()==1); 37 } 38 39 return boost::report_errors(); 40 } 41 42