4 // (C) Copyright 2009- Norihisa Nakai
5 // Distributed under the Boost Software License, Version 1.0
6 // (See accompanying file LICENSE_1_0.txt http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/noncopyable.hpp>
10 #include <boost/thread/exceptions.hpp>
14 namespace ultramonkey{
16 class spin_mutex : boost::noncopyable{
21 int const res = pthread_spin_init( &m, NULL );
22 if( res ) throw boost::thread_resource_error();
26 pthread_spin_destroy(&m);
29 void lock(){ pthread_spin_lock(&m); }
30 void unlock(){ pthread_spin_unlock(&m); }
32 int const res = pthread_spin_trylock(&m);
37 } // namespace ultramonkey