En Fri, 19 Mar 2010 23:31:23 -0300, MRAB <pyt...@mrabarnett.plus.com> escribió:
moerchendiser2k3 wrote:

 class SetPointer
{
private:
        void *ptr;
        MY_LOCK lock;
  public:
        void SetPointer(void *p)
        {
                Lock(this->lock);
                this->ptr = p;
        }

3. You're locking, but never unlocking. The sequence should be: lock, do
stuff, unlock.

Just FYI: C++ doesn't have try/finally, and such behavior is usually emulated using a local object. When it goes out of scope, it is automatically destroyed, meaning that the object destructor is called. Whatever you would write in a "finally" clause, in C++ goes into a destructor.

Of course C++ guys would never say they're "emulating" try/finally, instead they declare RAII as *the* Only and Right Way :)

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to