Boost logo

Boost Users :

From: Anders Sundman (anders.sundman_at_[hidden])
Date: 2007-02-08 07:22:59


Hi all!

I'm curious about the realization of the boost::mutex class (especially
on W32).

* How heavy is it to create a mutex object?

* Are there any limits (OS recource bound or other) to how many mutex
object that can be created?

* How costly is it to 're-lock' a recursive mutex? Almost NOP or more
costly?

Are these questions (and other of the same type) answered somewhere in
the docs?

Finally, a more concrete question. Consider the following:

A list of objects that needs to lock a mutex (all lock the same mutex).

vector<CriticalWorker*> foo;
...
for ( ... i = each foo ... )
   i->doWorkThatLocks();

This code section will lock/unlock repeatedly.

If I use a recursive mutex, will the following be much faster (since the
locks in 'doWorkThatLocks' will be more light-weight)?

lock();
for ( ... i = each foo ... )
   i->doWorkThatLocks();
unlock();

Best Regards
Anders Sundman


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