0
在一個類中失敗了,我想用一個互斥體在這樣的函數升壓的scoped_lock每次
void Agent::notify(Packet& packet, Peer peer) {
boost::mutex::scoped_lock lock(mutex_);
...
}
在編譯過程沒有問題。但是,當我執行程序,提高總是在這條線不能說:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
what(): boost: mutex lock failed in pthread_mutex_lock: Invalid argument
Abandon (core dumped)
我嘗試使用lock()
或unlock
方法,但同樣的問題。當我使用try_lock
它沒有失敗的條件總是錯誤的。
在互聯網上搜索我找到了這個https://svn.boost.org/trac/boost/ticket/9307。
但我認爲問題是我的程序,但我不知道在哪裏。在我的測試中,這個函數只有一個線程。
'mutex_'是如何聲明/定義的?它是遞歸鎖定的? –
boost :: mutex mutex_ – Saroupille