- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
A thread that owns a
recursive_mutex
object may acquire additional levels of ownership by callinglock()
ortry_lock()
on that object. It is unspecified how many levels of ownership may be acquired by a single thread. If a thread has already acquired the maximum level of ownership for arecursive_mutex
object, additional calls totry_lock()
shall fail, and additional calls tolock()
shall throw an exception of typesystem_error
.
“所有权的最高级别”是否有大于 1 的下限?递归 pthread 互斥锁怎么样?
最佳答案
标准中没有规定下限。这可能是故意的。
较旧的标准(我认为是 C)确实用于为此类事情提供下限。结果是人们编写了编码标准,规定您不能使用超过这些下限的值。例如:它曾经(我认为现在仍然是)实现定义了在比较相等时外部符号的多少个字符是重要的。所以 a_very_very_long_name_indeed_with_extra_padding
和 a_very_very_long_name_indeed_with_extra_paddingX
可能被视为相同的符号。最小长度被指定为 8 个字符,并且编写了编码标准来指定“外部符号的最大长度为八个字符”。
关于这个值的合理下限:我可以很容易地想象这个计数可能被打包到其他一些字段中,这样整个事情就可以用一个合适的指令自动更新。因此,少于 32 位可能会很划算。 (它只需要足够大以支持最大调用堆栈深度,因此在受限环境中,31 可能就足够了。)
关于c++ - recursive_mutex 的最大所有权级别的下限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37203741/
我有一个 recursive_mutex 案例,我正在尝试解决。这是解释问题的一段代码。 void OnConnectionDisconnected() { boost::l
引用 [thread.mutex.recursive] : A thread that owns a recursive_mutex object may acquire additional lev
在 boost::recursive_mutex::scoped_lock 上调用 unlock() 后,锁定对象是否会在其析构函数中以某种方式引用互斥量? 锁在解锁调用后仍然保留对互斥量的引用(即。
我有一个自定义类,它使用这样的 boost 互斥锁和锁(仅相关部分): template class FFTBuf { public: FFTBuf(); [.
我有以下多态接口(interface): struct service { virtual void connect(std::function(bool) cb); // Inv
当 condition_variable_any 与 recursive_mutex 一起使用时,recursive_mutex 是否通常可从其他线程获取,同时 condition_variable_
我有一个案例,我的算法的决定是基于共享 std::recursive_mutex 的深度。 #include #include #include int g_i = 0; std::recurs
我想知道当您移动包含 recursive_mutex 的 unique_lock 时会发生什么。 具体来说,我正在查看这段代码: recursive_mutex g_mutex; #define TR
根据this , unique_lock可通过声明 std::unique_lock 用于递归锁定,实际上编译得很好。 但是,从检查代码(gcc 4.8.2 和 4.9.0)看来,unique_loc
std::recursive_mutex 在 同一个 线程多次锁定它时不会死锁。 多个线程多次加锁会死锁吗? 最佳答案 Will it deadlock when multiple threads l
我怀疑基于我的代码的行为,如果我有一个 boost::thread_group 访问一个受 boost::recursive_mutex 保护的对象,那么互斥锁不会阻止组内的线程同时进入 protec
boost::recursive_mutex 和 boost::lock_guard 似乎在 C++ Builder 2010 中使用 boost_thread-bcb-mt-1_39.dll。我看到
我看到有人讨厌 recursive_mutex: http://www.zaval.org/resources/library/butenhof1.html 但是当考虑如何实现一个线程安全的类(互斥保
你能不能把 std::recursive_mutex 和 std::condition_variable 结合起来,意思是做这样的事情: std::unique_lock lock(some_recu
我正在阅读《C++ Concurrency In Action》一书,对 list 6.1 中使用的互斥体有一些疑问,代码片段如下: void pop(T& value) { std::loc
我是一名优秀的程序员,十分优秀!