////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Vicente J. Botet Escriba 2008. 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/sync for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_SYNC_NULL_MUTEX_HPP #define BOOST_SYNC_NULL_MUTEX_HPP #include //!\file //!Describes null_mutex classes namespace boost { namespace posix_time { class ptime; } namespace sync { //!Implements a mutex that simulates a mutex without doing any operation and //!simulates a successful operation. class null_mutex : lock_traits_base< mono_threaded_tag, upgradable_lock_tag, recursive_tag, has_timed_interface_tag, void > { /// @cond null_mutex(const null_mutex&); null_mutex &operator= (const null_mutex&); /// @endcond public: //!Constructor. //!Empty. null_mutex(){} //!Destructor. //!Empty. ~null_mutex(){} //!Simulates a mutex lock() operation. Empty function. void lock(){} //!Simulates a mutex try_lock() operation. //!Equivalent to "return true;" bool try_lock() { return true; } //!Simulates a mutex timed_lock() operation. //!Equivalent to "return true;" bool timed_lock(const boost::posix_time::ptime &) { return true; } //!Simulates a mutex unlock() operation. //!Empty function. void unlock(){} //!Simulates a mutex lock_share() operation. //!Empty function. void lock_share(){} //!Simulates a mutex try_lock_share() operation. //!Equivalent to "return true;" bool try_lock_share() { return true; } //!Simulates a mutex timed_lock_share() operation. //!Equivalent to "return true;" bool timed_lock_share(const boost::posix_time::ptime &) { return true; } //!Simulates a mutex unlock_share() operation. //!Empty function. void unlock_share(){} //!Simulates a mutex lock_upgrade() operation. //!Empty function. void lock_upgrade(){} //!Simulates a mutex try_lock_upgrade() operation. //!Equivalent to "return true;" bool try_lock_upgrade() { return true; } //!Simulates a mutex timed_lock_upgrade() operation. //!Equivalent to "return true;" bool timed_lock_upgrade(const boost::posix_time::ptime &) { return true; } //!Simulates a mutex unlock_upgrade() operation. //!Empty function. void unlock_upgrade(){} //!Simulates unlock_and_lock_upgrade(). //!Empty function. void unlock_and_lock_upgrade(){} //!Simulates unlock_and_lock_share(). //!Empty function. void unlock_and_lock_share(){} //!Simulates unlock_upgrade_and_lock_share(). //!Empty function. void unlock_upgrade_and_lock_share(){} //Promotions //!Simulates unlock_upgrade_and_lock(). //!Empty function. void unlock_upgrade_and_lock(){} //!Simulates try_unlock_upgrade_and_lock(). //!Equivalent to "return true;" bool try_unlock_upgrade_and_lock() { return true; } //!Simulates timed_unlock_upgrade_and_lock(). //!Equivalent to "return true;" bool timed_unlock_upgrade_and_lock(const boost::posix_time::ptime &) { return true; } //!Simulates try_unlock_share_and_lock(). //!Equivalent to "return true;" bool try_unlock_share_and_lock() { return true; } //!Simulates try_unlock_share_and_lock_upgrade(). //!Equivalent to "return true;" bool try_unlock_share_and_lock_upgrade() { return true; } }; } } #endif //BOOST_SYNC_NULL_MUTEX_HPP