Boost :: condition_variable waits without blocking

Is it possible to "wait" on boost :: condition_variable without having to lock the mutex first? If this is not possible, can this be done using pthread lib directly?

For simplicity, I would like to avoid going directly to the OS level (e.g. futex on linux). But I also don't want the overhead of calling a mutex.

I understand the conditions of the race, doing it under normal circumstances. It was different for me.

+3
source share
2 answers

Mutex must be obtained first in both cases.

From boost.threads file :

(:: unique_lock & )

: [...]

pthread_cond_wait man-:

pthread_cond_wait() pthread_cond_timedwait() . , undefined .

.

+6

, . API condition_variable, , unique_lock. , . "", - ...

0

Source: https://habr.com/ru/post/1775963/


All Articles