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_LOCKABLE_HPP
0012 #define BOOST_THREAD_POLY_LOCKABLE_HPP
0013 
0014 #include <boost/thread/detail/delete.hpp>
0015 #include <boost/chrono/chrono.hpp>
0016 
0017 namespace boost
0018 {
0019 
0020   //[basic_poly_lockable
0021   class basic_poly_lockable
0022   {
0023   public:
0024 
0025     virtual ~basic_poly_lockable() = 0;
0026 
0027     virtual void lock() = 0;
0028     virtual void unlock() = 0;
0029 
0030   };
0031   //]
0032 
0033   // A proper name for basic_poly_lockable, consistent with naming scheme of other polymorphic wrappers
0034   typedef basic_poly_lockable poly_basic_lockable;
0035 
0036   //[poly_lockable
0037   class poly_lockable : public basic_poly_lockable
0038   {
0039   public:
0040 
0041     virtual ~poly_lockable() = 0;
0042     virtual bool try_lock() = 0;
0043   };
0044   //]
0045 
0046   //[timed_poly_lockable
0047   class timed_poly_lockable: public poly_lockable
0048   {
0049   public:
0050     virtual ~timed_poly_lockable()=0;
0051 
0052     virtual bool try_lock_until(chrono::system_clock::time_point const & abs_time)=0;
0053     virtual bool try_lock_until(chrono::steady_clock::time_point const & abs_time)=0;
0054     template <typename Clock, typename Duration>
0055     bool try_lock_until(chrono::time_point<Clock, Duration> const & abs_time)
0056     {
0057       return try_lock_until(chrono::time_point_cast<Clock::time_point>(abs_time));
0058     }
0059 
0060     virtual bool try_lock_for(chrono::nanoseconds const & relative_time)=0;
0061     template <typename Rep, typename Period>
0062     bool try_lock_for(chrono::duration<Rep, Period> const & rel_time)
0063     {
0064       return try_lock_for(chrono::duration_cast<chrono::nanoseconds>(rel_time));
0065     }
0066 
0067   };
0068   //]
0069 
0070   // A proper name for timed_poly_lockable, consistent with naming scheme of other polymorphic wrappers
0071   typedef timed_poly_lockable poly_timed_lockable;
0072 }
0073 #endif