Boost logo

Threads-Devel :

Subject: Re: [Threads-devel] shared_lock() causes Segmentation Fault in CentOS 5.5 x64?
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2011-03-15 08:52:00


On Monday, March 14, 2011, Zap wrote:
> bool apInfoTable::getFD(list<int> *des, char *type, char *code){
> bool flag=false;
> boost::shared_lock<boost::shared_mutex> lock(rwMutex);
> for(boost::unordered_set<int>::iterator it=tablePush[pair<string,
> string> (type, code)].begin();it!=tablePush[pair<string, string>(type,
> code)].end ();it++){
> flag=true;
> des->push_back(*it);
> }
> return flag;
> }

You should be using unique_lock instead of shared_lock if you are a writer.
shared_lock is for readers.


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk