我可以在超出scoped_lock範圍之前解鎖互斥鎖嗎?我怎麼能這樣做?boost :: scoped_lock unlock
{boost::mutex::scoped_lock lock(mutex);
if(conditionaA)
{
if(conditionB)
{
//could I unlock here as I don't want to hold the lock too long.
//perform calculation
}
}
else
{
}
}//lock scope
謝謝。
由於沒有閱讀文檔,因此我會加倍降低速度,因爲谷歌會將解決方案顯示爲「scoped_lock unlock」的第一個結果,因爲解鎖方法稱爲解鎖,所以三倍速率下降。 – 2011-01-11 09:35:30