This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

std::try_lock problems


I think we need something like the attached patch to fix two problems
in our std::try_lock:

1) exceptions are not caught (leaving the caller no way to know which
locks are held)

2) if a try_lock fails we call unlock on the failed lock, we should
only unlock the ones that succeeded

I need a version of std::lock() so am implementing that too.  In that
case I believe we do want to propagate exceptions, which means we need
to use RAII to do the unlocking.  I'm working on a simpler RAII-based
version of try_lock_impl which can work for both try_lock and lock,
and am writing tests to exercise the exceptional paths.

If anyone has any good ideas for a try-and-back-off algorithm let me
know, my current version is very basic.

Attachment: try_lock.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]