Boost logo

Threads-Devel :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2007-11-27 09:09:59


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 27 November 2007 03:06 am, Anthony Williams wrote:
> > error: ‘class boost::unique_lock<boost::mutex>’ has no member named
> > ‘locked’
>
> Where does that error come from? The condition variable code doesn't use a
> locked() function, nor does unique_lock provide one.

I've attached a small program that generates the error when I try to compile
it. It's not actually related to conditions, all I have to do is try to use
the locked() member of boost::mutex::scoped_lock (which is apparently a
unique_lock). Maybe the docs just haven't been updated (the Lock concept
still says it requires a locked() member function, and a cast to const
void*).

> The new trunk code provides two condition variable types:
> condition_variable and condition_variable_any.
>
> condition_variable works with unique_lock<mutex> ONLY, and the function
> signatures are explicit about that. condition_variable_any will work with
> anything that supports unlock() and lock().

Ah, good to hear.

- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHTCU/5vihyNWuA4URAuawAKDSWmLzE0pi1fcddsNjeU/JsJXPzgCfdy9+
BlcLaw8H+qxBINWHeESJpoE=
=E3gO
-----END PGP SIGNATURE-----

--Boundary-00=_/UCTHsKHLeIJ5d+
Content-Type: text/x-c++src; charset="iso-8859-1";
        name="lock_compile_error.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
        filename="lock_compile_error.cpp"

#include <boost/thread/mutex.hpp>
#include <iostream>

int main()
{
        boost::mutex mut;
        boost::mutex::scoped_lock lock(mut);
        std::cout << "locked returns " << lock.locked() << std::endl;
        return 0;
}

--Boundary-00=_/UCTHsKHLeIJ5d+--


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