Documentation Home >> Concepts >> TimedLockable Concept

In order to meet the requirements of the TimedLockable concept, a type must meet the Lockable requirements. In addition, it must also support try_lock_for() and try_lock_until() member functions with the following signatures and semantics:

struct timed-lockable-type
{
    // required by the Lockable concept
    void lock();
    void unlock();
    bool try_lock();

    // additional members required for TimedLockable
    template<typename Rep,typename Period>
    bool try_lock_for(
        std::chrono::duration<Rep,Period> const&
        relative_time);

    template<typename Clock,typename Duration>
    bool try_lock_until(
        std::chrono::time_point<Clock,Duration> const&
        absolute_time);
};
try_lock_for() Requirements

For an instance m of a TimedLockable type and a value relative_time of an instantiation of the std::chrono::duration class template, the expression m.try_lock_for(relative_time) shall attempt to acquire a lock for the current thread of execution within the specified time period. The function shall return true if the lock was acquired, false otherwise. The elapsed time for the duration shall be measured with a steady clock where possible.

try_lock_until() Requirements

For an instance m of a TimedLockable type and a value absolute_time of an instantiation of the std::chrono::time_point class template, the expression m.try_lock_until(absolute_time) shall attempt to acquire a lock for the current thread of execution before the specified time. The function shall return true if the lock was acquired, false otherwise.

See Also