# C++ named requirements: TimedLockable (since C++11)

> C++ Atlas: `cppatlas.com/w/cpp/named_req/TimedLockable` | Source: https://en.cppreference.com/w/cpp/named_req/TimedLockable | Domain: Named Requirements | Standards: C++11, C++14

The TimedLockable requirements describe the characteristics of types that provide timed exclusive blocking semantics for execution agents (threads, processes, tasks).

## Official Specification Summary (cppreference)

The *TimedLockable* requirements describe the characteristics of types that provide timed exclusive blocking semantics for execution agents (threads, processes, tasks).

### Requirements

- *Lockable*

For type `L` to be *TimedLockable*, given

- `rel_time`, a value of a specialization of `std::chrono::duration`, and
- `abs_time`, a value of a specialization of `std::chrono::time_point`,

the following conditions have to be satisfied for an object `m` of type `L`:

| Expression | Effects | Return value |
| --- | --- | --- |
| `m.try_lock_for(rel_time)` | Blocks for the provided duration `rel_time` or until a lock on `m` is acquired. | `true` if the lock was acquired, `false` otherwise. |
| `m.try_lock_until(abs_time)` | Blocks until the provided time point `abs_time` is reached or a lock on `m` is acquired. | `true` if the lock was acquired, `false` otherwise. |

### Notes

The `try_lock_for` and `try_lock_until` member functions obtain a non-shared lock on `m` on success.

### Standard library

The following standard library types satisfy *TimedLockable*:

- `timed_mutex` (C++11): provides mutual exclusion facility which implements locking with a timeout (class)
- `recursive_timed_mutex` (C++11): provides mutual exclusion facility which can be locked recursively by the same thread and implements locking with a timeout (class)
- `shared_timed_mutex` (C++14): provides shared mutual exclusion facility and implements locking with a timeout (class)

### See also

- [Thread support library](https://en.cppreference.com/w/cpp/thread)
- [*TimedMutex*](https://en.cppreference.com/w/cpp/named_req/TimedMutex)
- [*Lockable*](https://en.cppreference.com/w/cpp/named_req/Lockable)
- [*BasicLockable*](https://en.cppreference.com/w/cpp/named_req/BasicLockable)

---
Attribution: content from https://en.cppreference.com/w/cpp/named_req/TimedLockable (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.