Boost logo

Boost Users :

Subject: Re: [Boost-users] newbie thread synchronization question
From: Igor R (boost.lists_at_[hidden])
Date: 2009-03-01 14:35:56


>
> If I use it in from multiple threads with code that looks like:
> // s is an instance of Shared
> s.lock();
> int q = s.getQty();
> ++q;
> s.setQty(q);
> s.unlock();
>
It's correct locking, but if getQty/setQty throw, the object never gets
unlocked. So it's worth useing some RAII-style technique.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net