Boost logo

Boost Users :

Subject: [Boost-users] [boost][thread] Breaking Changes
From: Andrey Torba (andreytorba_at_[hidden])
Date: 2009-07-15 07:24:10


Hi all!
One of breaking changes of boost.thread since 1.34 are changes in the
scoped_lock interface:
was:
boost::mutex::scoped_lock some_lock(some_mutex,false);
now:
boost::mutex::scoped_lock some_lock(some_mutex,boost::defer_lock);

I update boost. So i have many methods in a project which accepts a
boolean variable initial_lock.
void c::fff(bool initial_lock)
{
  scoped_lock lk(m_mutex, initial_lock);
// do fff
....
}

Now it's impossible because of different types:
    const defer_lock_t defer_lock={};
    const try_to_lock_t try_to_lock={};
    const adopt_lock_t adopt_lock={};

For example if with boost 1.33 method looked like:
void c::fff(bool initial_lock)
{
  scoped_lock lk(m_mutex, initial_lock);
// do fff
....
}

what kind of refactoring should i do? to pass locking strategy as a
template parameter?
template<class Lock>
void c::fff(Lock initial_lock)
{
  scoped_lock lk(m_mutex, initial_lock);
  invoke_fff();
}

What was the reason to have a different locking types and not
enum{defer_lock, try_to_lock, adopt_lock}.
Does aproach lead to any errors?

--
Regards, Andrey

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