Boost C++ Libraries

PrevUpHomeNext

Class template unique_lock

boost::sync::unique_lock — A unique lock scope guard.

Synopsis

// In header: <boost/sync/locks/unique_lock.hpp>

template<typename Mutex> 
class unique_lock {
public:
  // types
  typedef Mutex mutex_type;

  // construct/copy/destruct
  unique_lock() noexcept;
  explicit unique_lock(mutex_type &);
  unique_lock(mutex_type &, adopt_lock_t) noexcept;
  unique_lock(mutex_type &, defer_lock_t) noexcept;
  unique_lock(mutex_type &, try_to_lock_t);
  template<typename Time> unique_lock(unspecified, Time const &);
  unique_lock(unique_lock &&) noexcept;
  explicit unique_lock(upgrade_lock< mutex_type > &&);
  unique_lock(upgrade_lock< mutex_type > &&, try_to_lock_t);
  unique_lock(shared_lock< mutex_type > &&, try_to_lock_t);
  template<typename Time> 
    unique_lock(shared_lock< mutex_type > &&, Time const &, unspecified = 0);
  unique_lock & operator=(unique_lock &&) noexcept;
  unique_lock & operator=(upgrade_lock< mutex_type > &&);
  ~unique_lock();

  // public member functions
  void lock();
  bool try_lock();
  template<typename Time> unspecified timed_lock(Time const &);
  template<typename Duration> unspecified try_lock_for(Duration const &);
  template<typename TimePoint> unspecified try_lock_until(TimePoint const &);
  void unlock();
  explicit operator bool() const;
  bool operator!() const noexcept;
  bool owns_lock() const noexcept;
  mutex_type * mutex() const noexcept;
  mutex_type * release() noexcept;
  void swap(unique_lock &) noexcept;
};

Description

unique_lock public construct/copy/destruct

  1. unique_lock() noexcept;
  2. explicit unique_lock(mutex_type & m);
  3. unique_lock(mutex_type & m, adopt_lock_t) noexcept;
  4. unique_lock(mutex_type & m, defer_lock_t) noexcept;
  5. unique_lock(mutex_type & m, try_to_lock_t);
  6. template<typename Time> unique_lock(unspecified m, Time const & t);
  7. unique_lock(unique_lock && that) noexcept;
  8. explicit unique_lock(upgrade_lock< mutex_type > && that);
  9. unique_lock(upgrade_lock< mutex_type > && ul, try_to_lock_t);
  10. unique_lock(shared_lock< mutex_type > && sl, try_to_lock_t);
  11. template<typename Time> 
      unique_lock(shared_lock< mutex_type > && sl, Time const & t, 
                  unspecified = 0);
  12. unique_lock & operator=(unique_lock && that) noexcept;
  13. unique_lock & operator=(upgrade_lock< mutex_type > && that);
  14. ~unique_lock();

unique_lock public member functions

  1. void lock();
  2. bool try_lock();
  3. template<typename Time> unspecified timed_lock(Time const & time);
  4. template<typename Duration> 
      unspecified try_lock_for(Duration const & rel_time);
  5. template<typename TimePoint> 
      unspecified try_lock_until(TimePoint const & abs_time);
  6. void unlock();
  7. explicit operator bool() const;
  8. bool operator!() const noexcept;
  9. bool owns_lock() const noexcept;
  10. mutex_type * mutex() const noexcept;
  11. mutex_type * release() noexcept;
  12. void swap(unique_lock & that) noexcept;

PrevUpHomeNext