首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

mutex

此标头是螺纹支撑图书馆。

*。

互斥量%28C++11%29提供基本互斥设施%28类%29

定时[医]互斥锁%28C++11%29提供互斥功能,它使用超时%28class%29实现锁定

递归[医]Mutex%28C++11%29提供了互斥功能,可以通过同一个线程%28class 29递归地锁定

递归[医]定时[医]互斥对象%28C++11%29提供了互斥功能,可以通过同一个线程递归地锁定,并通过超时%28class 29实现锁定。

锁[医]保护%28C++11%29实现严格基于范围的互斥拥有包装器%28类模板%29。

独树一帜[医]锁%28C++11%29实现可移动互斥拥有包装器%28类模板%29

推迟[医]锁[医]试试看[医]到[医]锁[医]采行[医]锁[医]T%28C++11%29%28C+11%29%28C+11%29标签类型用于指定锁定策略%28class%29

推迟[医]锁[医]到[医]锁具[医]锁%28C++11%29%28C+11%29%28C+11%29个标签常量用于指定锁定策略%28常数%29

一次[医]标志%28C++11%29助手对象以确保调用[医]一次只调用一次函数%28class%29

功能

试一试[医]锁%28C++11%29尝试通过多次调用获得互斥的所有权[医]锁%28功能模板%29

锁%28C++11%29锁指定互斥锁,如果有的话块不可用%28功能模板%29

打电话[医]一旦%28C++11%29只调用一次函数,即使从多线程调用了%28函数模板%29

STD::SWAP%28std::UNIQUE[医]锁%29%28C++11%29专门化的std::swapforUNIQUE[医]锁%28功能模板%29

简介

二次

代码语言:javascript
复制
namespace std {
    class mutex;
    class recursive_mutex;
    class timed_mutex;
    class recursive_timed_mutex;
 
    struct defer_lock_t { explicit defer_lock_t() = default; };
    inline constexpr defer_lock_t defer_lock { };
 
    struct try_to_lock_t { explicit try_to_lock_t() = default; };
    inline constexpr try_to_lock_t try_to_lock { };
 
    struct adopt_lock_t { explicit adopt_lock_t() = default; };
    inline constexpr adopt_lock_t adopt_lock { };
 
    template <class Mutex> class lock_guard;
    template <class Mutex> class unique_lock;
 
    template <class Mutex>
    void swap(unique_lock<Mutex>& x,
              unique_lock<Mutex>& y) noexcept;
 
    template <class L1, class L2, class... L3>
    int try_lock(L1&, L2&, L3&...);
 
    template <class L1, class L2, class... L3>
    void lock(L1&, L2&, L3&...);
 
    struct once_flag;
 
    template<class Callable, class ...Args>
    void call_once(once_flag& flag, Callable func, Args&&... args);
}

二次

std::mutex

二次

代码语言:javascript
复制
class mutex {
 public:
    constexpr mutex() noexcept;
    ~mutex();
    mutex(const mutex&) = delete;
    mutex& operator=(const mutex&) = delete;
 
    void lock();
    bool try_lock();
    void unlock();
    typedef /*implementation-defined*/ native_handle_type;
    native_handle_type native_handle();
};

二次

std::recursive_mutex

二次

代码语言:javascript
复制
class recursive_mutex {
 public:
    recursive_mutex();
    ~recursive_mutex();
    recursive_mutex(const recursive_mutex&) = delete;
    recursive_mutex& operator=(const recursive_mutex&) = delete;
 
    void lock();
    bool try_lock() noexcept;
    void unlock();
    typedef /*implementation-defined*/ native_handle_type;
    native_handle_type native_handle();
};

二次

std::timed_mutex

二次

代码语言:javascript
复制
class timed_mutex {
 public:
    timed_mutex();
    ~timed_mutex();
    timed_mutex(const timed_mutex&) = delete;
    timed_mutex& operator=(const timed_mutex&) = delete;
 
    void lock();
    bool try_lock();
    template <class Rep, class Period>
        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
    template <class Clock, class Duration>
        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
    void unlock();
    typedef /*implementation-defined*/ native_handle_type;
    native_handle_type native_handle();
};

二次

std::recursive_timed_mutex

二次

代码语言:javascript
复制
class recursive_timed_mutex {
 public:
    recursive_timed_mutex();
    ~recursive_timed_mutex();
    recursive_timed_mutex(const recursive_timed_mutex&) = delete;
    recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
 
    void lock();
    bool try_lock() noexcept;
    template <class Rep, class Period>
        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
    template <class Clock, class Duration>
        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
    void unlock();
    typedef /*implementation-defined*/ native_handle_type;
    native_handle_type native_handle();
};

二次

std::lock_guard

二次

代码语言:javascript
复制
template <class Mutex>
class lock_guard {
 public:
    typedef Mutex mutex_type;
    explicit lock_guard(mutex_type& m);
    lock_guard(mutex_type& m, adopt_lock_t);
    ~lock_guard();
    lock_guard(lock_guard const&) = delete;
    lock_guard& operator=(lock_guard const&) = delete;
 private:
    mutex_type& pm; // exposition only
};

二次

std::unique_lock

二次

代码语言:javascript
复制
template <class Mutex>
class unique_lock {
 public:
    typedef Mutex mutex_type;
 
    // construct/copy/destroy:
    unique_lock() noexcept;
    explicit unique_lock(mutex_type& m);
    unique_lock(mutex_type& m, defer_lock_t) noexcept;
    unique_lock(mutex_type& m, try_to_lock_t);
    unique_lock(mutex_type& m, adopt_lock_t);
    template <class Clock, class Duration>
    unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
    template <class Rep, class Period>
    unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
    ~unique_lock();
    unique_lock(unique_lock const&) = delete;
    unique_lock& operator=(unique_lock const&) = delete;
    unique_lock(unique_lock&& u) noexcept;
    unique_lock& operator=(unique_lock&& u) noexcept;
 
    // locking:
    void lock();
    bool try_lock();
    template <class Rep, class Period>
    bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
    template <class Clock, class Duration>
    bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
    void unlock();
 
    // modifiers:
    void swap(unique_lock& u) noexcept;
    mutex_type *release() noexcept;
 
    // observers:
    bool owns_lock() const noexcept;
    explicit operator bool () const noexcept;
    mutex_type* mutex() const noexcept;
 
 private:
    mutex_type *pm; // exposition only
    bool owns; // exposition only
};

二次

std::once_flag

二次

代码语言:javascript
复制
struct once_flag {
    constexpr once_flag() noexcept;
    once_flag(const once_flag&) = delete;
    once_flag& operator=(const once_flag&) = delete;
};

二次

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com