folly::try_transition_to_unique_lock_for

try_transition_to_unique_lock_for overloads

Synopses

Declared in <folly/synchronization/Lock.h>

Attempts, up to a timeout, to atomically upgrade a shared lock to an exclusive lock.

template<
    typename Mutex,
    typename Rep,
    typename Period>
unique_lock<Mutex>
try_transition_to_unique_lock_for(
    shared_lock<Mutex>& lock,
    std::chrono::duration<Rep, Period> const& timeout);
» more...

Attempts, up to a timeout, to atomically upgrade an upgrade lock to an exclusive lock.

template<
    typename Mutex,
    typename Rep,
    typename Period>
unique_lock<Mutex>
try_transition_to_unique_lock_for(
    upgrade_lock<Mutex>& lock,
    std::chrono::duration<Rep, Period> const& timeout);
» more...

Return Value

An exclusive lock holder; empty if the attempt failed.

Parameters

NameDescription
lockThe shared lock holder to transition from.
timeoutThe maximum duration to wait for.