我可以在超出scoped_lock范围之前解锁互斥锁吗?我怎么能这样做?
{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
Run Code Online (Sandbox Code Playgroud)
谢谢.
Kaz*_*gon 16
是.
使用该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.
lock.unlock(); // <--
}
//perform calculation
}
else
{
}
}//lock scope
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8468 次 |
| 最近记录: |