Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:09:31

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/thread for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_THREAD_POLY_SHARED_LOCKABLE_HPP
0012 #define BOOST_THREAD_POLY_SHARED_LOCKABLE_HPP
0013 
0014 #include <boost/thread/poly_lockable.hpp>
0015 #include <boost/chrono/chrono.hpp>
0016 
0017 namespace boost
0018 {
0019 
0020 
0021   //[shared_poly_lockable
0022   class shared_poly_lockable: public timed_poly_lockable
0023   {
0024   public:
0025     virtual ~shared_poly_lockable() = 0;
0026 
0027     virtual void lock_shared() = 0;
0028     virtual bool try_lock_shared() = 0;
0029     virtual void unlock_shared() = 0;
0030 
0031     virtual bool try_lock_shared_until(chrono::system_clock::time_point const & abs_time)=0;
0032     virtual bool try_lock_shared_until(chrono::steady_clock::time_point const & abs_time)=0;
0033     template <typename Clock, typename Duration>
0034     bool try_lock_shared_until(chrono::time_point<Clock, Duration> const & abs_time)
0035     {
0036       return try_lock_shared_until(chrono::time_point_cast<Clock::time_point>(abs_time));
0037     }
0038 
0039     virtual bool try_lock_shared_for(chrono::nanoseconds const & relative_time)=0;
0040     template <typename Rep, typename Period>
0041     bool try_lock_shared_for(chrono::duration<Rep, Period> const & rel_time)
0042     {
0043       return try_lock_shared_for(chrono::duration_cast<chrono::nanoseconds>(rel_time));
0044     }
0045 
0046   };
0047   //]
0048 
0049   // A proper name for shared_poly_lockable, consistent with naming scheme of other polymorphic wrappers
0050   typedef shared_poly_lockable poly_shared_lockable;
0051 
0052   //[upgrade_poly_lockable
0053   class upgrade_poly_lockable: public shared_poly_lockable
0054   {
0055   public:
0056     virtual ~upgrade_poly_lockable() = 0;
0057 
0058     virtual void lock_upgrade() = 0;
0059     virtual bool try_lock_upgrade() = 0;
0060     virtual void unlock_upgrade() = 0;
0061 
0062     virtual bool try_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)=0;
0063     virtual bool try_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)=0;
0064     template <typename Clock, typename Duration>
0065     bool try_lock_upgrade_until(chrono::time_point<Clock, Duration> const & abs_time)
0066     {
0067       return try_lock_upgrade_until(chrono::time_point_cast<Clock::time_point>(abs_time));
0068     }
0069 
0070     virtual bool try_lock_upgrade_for(chrono::nanoseconds const & relative_time)=0;
0071     template <typename Rep, typename Period>
0072     bool try_lock_upgrade_for(chrono::duration<Rep, Period> const & rel_time)
0073     {
0074       return try_lock_upgrade_for(chrono::duration_cast<chrono::nanoseconds>(rel_time));
0075     }
0076 
0077     virtual bool try_unlock_shared_and_lock() = 0;
0078 
0079     virtual bool try_unlock_shared_and_lock_until(chrono::system_clock::time_point const & abs_time)=0;
0080     virtual bool try_unlock_shared_and_lock_until(chrono::steady_clock::time_point const & abs_time)=0;
0081     template <typename Clock, typename Duration>
0082     bool try_unlock_shared_and_lock_until(chrono::time_point<Clock, Duration> const & abs_time)
0083     {
0084       return try_unlock_shared_and_lock_until(chrono::time_point_cast<Clock::time_point>(abs_time));
0085     }
0086 
0087     virtual bool try_unlock_shared_and_lock_for(chrono::nanoseconds const & relative_time)=0;
0088     template <typename Rep, typename Period>
0089     bool try_unlock_shared_and_lock_for(chrono::duration<Rep, Period> const & rel_time)
0090     {
0091       return try_unlock_shared_and_lock_for(chrono::duration_cast<chrono::nanoseconds>(rel_time));
0092     }
0093 
0094     virtual void unlock_and_lock_shared() = 0;
0095     virtual bool try_unlock_shared_and_lock_upgrade() = 0;
0096 
0097     virtual bool try_unlock_shared_and_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)=0;
0098     virtual bool try_unlock_shared_and_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)=0;
0099     template <typename Clock, typename Duration>
0100     bool try_unlock_shared_and_lock_upgrade_until(chrono::time_point<Clock, Duration> const & abs_time)
0101     {
0102       return try_unlock_shared_and_lock_upgrade_until(chrono::time_point_cast<Clock::time_point>(abs_time));
0103     }
0104 
0105     virtual bool try_unlock_shared_and_lock_upgrade_for(chrono::nanoseconds const & relative_time)=0;
0106     template <typename Rep, typename Period>
0107     bool try_unlock_shared_and_lock_upgrade_for(chrono::duration<Rep, Period> const & rel_time)
0108     {
0109       return try_unlock_shared_and_lock_upgrade_for(chrono::duration_cast<chrono::nanoseconds>(rel_time));
0110     }
0111 
0112     virtual void unlock_and_lock_upgrade() = 0;
0113     virtual void unlock_upgrade_and_lock() = 0;
0114     virtual bool try_unlock_upgrade_and_lock() = 0;
0115 
0116     virtual bool try_unlock_upgrade_and_lock_until(chrono::system_clock::time_point const & abs_time)=0;
0117     virtual bool try_unlock_upgrade_and_lock_until(chrono::steady_clock::time_point const & abs_time)=0;
0118     template <typename Clock, typename Duration>
0119     bool try_unlock_upgrade_and_lock_until(chrono::time_point<Clock, Duration> const & abs_time)
0120     {
0121       return try_unlock_upgrade_and_lock_until(chrono::time_point_cast<Clock::time_point>(abs_time));
0122     }
0123 
0124     virtual bool try_unlock_upgrade_and_lock_for(chrono::nanoseconds const & relative_time)=0;
0125     template <typename Rep, typename Period>
0126     bool try_unlock_upgrade_and_lock_for(chrono::duration<Rep, Period> const & rel_time)
0127     {
0128       return try_unlock_upgrade_and_lock_for(chrono::duration_cast<chrono::nanoseconds>(rel_time));
0129     }
0130 
0131     virtual void unlock_upgrade_and_lock_shared() = 0;
0132 
0133   };
0134   //]
0135 
0136   // A proper name for upgrade_poly_lockable, consistent with naming scheme of other polymorphic wrappers
0137   typedef upgrade_poly_lockable poly_upgrade_lockable;
0138 }
0139 #endif