33 Thread support library [thread]

33.4 Mutual exclusion [thread.mutex]

33.4.3 Mutex requirements [thread.mutex.requirements]

33.4.3.5 Shared timed mutex types [thread.sharedtimedmutex.requirements]

33.4.3.5.1 Class shared_­timed_­mutex [thread.sharedtimedmutex.class]

namespace std {
  class shared_timed_mutex {
  public:
    shared_timed_mutex();
    ~shared_timed_mutex();

    shared_timed_mutex(const shared_timed_mutex&) = delete;
    shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;

    // Exclusive ownership
    void lock();  // blocking
    bool try_lock();
    template <class Rep, class Period>
      bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
    template <class Clock, class Duration>
      bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
    void unlock();

    // Shared ownership
    void lock_shared();  // blocking
    bool try_lock_shared();
    template <class Rep, class Period>
      bool
      try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
    template <class Clock, class Duration>
      bool
      try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
    void unlock_shared();
  };
}

Класс shared_­timed_­mutex предоставляет нерекурсивный мьютекс с семантикой совместного владения.

Класс shared_­timed_­mutex должен удовлетворять всем требованиям shared timed mutex requirements. Это должен быть класс стандартной компоновки (пункт [class]).

Поведение программы не определено, если:

  • он уничтожает shared_­timed_­mutex объект, принадлежащий любому потоку,

  • поток пытается рекурсивно получить право собственности на a shared_­timed_­mutex, или

  • поток завершается, когда ему принадлежит какое-либо право собственности на a shared_­timed_­mutex.