Files
interprocess/test/named_recursive_mutex_test.cpp
Ion Gaztañaga 550a9de8c5 First complete documentation version
[SVN r34819]
2006-08-04 19:54:15 +00:00

77 lines
2.7 KiB
C++

//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztañaga 2004-2006. Distributed under 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)
//
// See http://www.boost.org/libs/interprocess for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/sync/named_recursive_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include "mutex_test_template.hpp"
#include "named_creation_template.hpp"
struct deleter
{
~deleter()
{ boost::interprocess::named_recursive_mutex::remove("named_recursive_mutex"); }
};
//This wrapper is necessary to have a default constructor
//in generic mutex_test_template functions
class named_recursive_mutex_lock_test_wrapper
: public boost::interprocess::named_recursive_mutex
{
public:
named_recursive_mutex_lock_test_wrapper()
: boost::interprocess::named_recursive_mutex
(boost::interprocess::open_or_create, "named_recursive_mutex")
{}
};
//This wrapper is necessary to have a common constructor
//in generic named_creation_template functions
class named_mutex_creation_test_wrapper
: public deleter, public boost::interprocess::named_recursive_mutex
{
public:
named_mutex_creation_test_wrapper(boost::interprocess::detail::create_only_t)
: boost::interprocess::named_recursive_mutex
(boost::interprocess::create_only, "named_recursive_mutex")
{}
named_mutex_creation_test_wrapper(boost::interprocess::detail::open_only_t)
: boost::interprocess::named_recursive_mutex
(boost::interprocess::open_only, "named_recursive_mutex")
{}
named_mutex_creation_test_wrapper(boost::interprocess::detail::open_or_create_t)
: boost::interprocess::named_recursive_mutex
(boost::interprocess::open_or_create, "named_recursive_mutex")
{}
};
int main ()
{
using namespace boost::interprocess;
try{
named_recursive_mutex::remove("named_recursive_mutex");
test::test_named_creation<named_mutex_creation_test_wrapper>();
test::test_all_lock<named_recursive_mutex_lock_test_wrapper>();
test::test_all_mutex<false, named_recursive_mutex_lock_test_wrapper>();
test::test_all_recursive_lock<named_recursive_mutex_lock_test_wrapper>();
}
catch(std::exception &ex){
std::cout << ex.what() << std::endl;
return 1;
}
return 0;
}
#include <boost/interprocess/detail/config_end.hpp>