Files
2025-10-25 03:02:53 +03:00

7.4 KiB

[thread.lock.shared.locking]

32 Concurrency support library [thread]

32.6 Mutual exclusion [thread.mutex]

32.6.5 Locks [thread.lock]

32.6.5.5 Class template shared_lock [thread.lock.shared]

32.6.5.5.3 Locking [thread.lock.shared.locking]

🔗

void lock();

1

#

Effects: As if by pm->lock_shared().

2

#

Postconditions: owns == true.

3

#

Throws: Any exception thrown by pm->lock_shared().

system_error when an exception is required ([thread.req.exception]).

4

#

Error conditions:

  • (4.1)

    operation_not_permitted — if pm is nullptr.

  • (4.2)

    resource_deadlock_would_occur — if on entry owns istrue.

🔗

bool try_lock();

5

#

Effects: As if by pm->try_lock_shared().

6

#

Postconditions: owns == res, where res is the value returned by the call to pm->try_lock_shared().

7

#

Returns: The value returned by the call to pm->try_lock_shared().

8

#

Throws: Any exception thrown by pm->try_lock_shared().

system_error when an exception is required ([thread.req.exception]).

9

#

Error conditions:

  • (9.1)

    operation_not_permitted — if pm is nullptr.

  • (9.2)

    resource_deadlock_would_occur — if on entry owns istrue.

🔗

template<class Clock, class Duration> bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);

10

#

Preconditions: Mutex meets the Cpp17SharedTimedLockable requirements ([thread.req.lockable.shared.timed]).

11

#

Effects: As if by pm->try_lock_shared_until(abs_time).

12

#

Postconditions: owns == res, where res is the value returned by the call to pm->try_lock_shared_until(abs_time).

13

#

Returns: The value returned by the call topm->try_lock_shared_until(abs_time).

14

#

Throws: Any exception thrown by pm->try_lock_shared_until(abs_time).

system_error when an exception is required ([thread.req.exception]).

15

#

Error conditions:

  • (15.1)

    operation_not_permitted — if pm is nullptr.

  • (15.2)

    resource_deadlock_would_occur — if on entry owns istrue.

🔗

template<class Rep, class Period> bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);

16

#

Preconditions: Mutex meets the Cpp17SharedTimedLockable requirements ([thread.req.lockable.shared.timed]).

17

#

Effects: As if by pm->try_lock_shared_for(rel_time).

18

#

Postconditions: owns == res, where res is the value returned by the call to pm->try_lock_shared_for(rel_time).

19

#

Returns: The value returned by the call to pm->try_lock_shared_for(rel_time).

20

#

Throws: Any exception thrown by pm->try_lock_shared_for(rel_time).

system_error when an exception is required ([thread.req.exception]).

21

#

Error conditions:

  • (21.1)

    operation_not_permitted — if pm is nullptr.

  • (21.2)

    resource_deadlock_would_occur — if on entry owns istrue.

🔗

void unlock();

22

#

Effects: As if by pm->unlock_shared().

23

#

Postconditions: owns == false.

24

#

Throws: system_error when an exception is required ([thread.req.exception]).

25

#

Error conditions:

operation_not_permitted — if on entry owns isfalse.