oneTBB icon indicating copy to clipboard operation
oneTBB copied to clipboard

Uable to use std::unique_lock with tbb::speculative_spin_mutex with gcc -mrtm on

Open Enjoysnow opened this issue 3 years ago • 3 comments

Uable to use std::unique_lock with tbb::speculative_spin_mutex with gcc -mrtm on.

When I turn on the gcc -mrtm option, tbb::speculative_spin_mutex becomes a type alias of tbb::detail::d1::rtm_mutex, https://github.com/oneapi-src/oneTBB/blob/534428d0f80538f500d524f037373cf61d721caf/include/oneapi/tbb/spin_mutex.h#L126 tbb::detail::d1::rtm_mutex has a base class tbb::spin_mutex which is marked as private, https://github.com/oneapi-src/oneTBB/blob/534428d0f80538f500d524f037373cf61d721caf/include/oneapi/tbb/detail/_rtm_mutex.h#L44 Cause that std::unique_lock can't access the required lock()/try_lock()/unlock() methods.

Enjoysnow avatar Dec 23 '21 08:12 Enjoysnow

@kboyarinov, do I understand correctly that C++11 std::unique_lock is by design not usable with rtm_mutex ?

anton-potapov avatar Dec 29 '21 09:12 anton-potapov

@kboyarinov ping

anton-potapov avatar Jan 18 '22 05:01 anton-potapov

Hi, @Enjoysnow,

As @anton-potapov mentioned, rtm_mutex is not usable with std::unique_lock by design because of absence of lock/unlock methods. Speculation logic in rtm_mutex is implemented inside of rtm_mutex::scoped_lock class, so it cannot be locked in other way. This class can also be used for RAII-locking of speculative_mutex as it is done with std::unique_lock.

kboyarinov avatar Feb 03 '22 15:02 kboyarinov

@Enjoysnow is this issue still relevant for you? Could you please respond?

isaevil avatar Oct 05 '22 11:10 isaevil

Closing this issue since no response. Feel free to reopen if any questions are left.

isaevil avatar Oct 13 '22 08:10 isaevil