Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Pete Becker Newsgroups: comp.std.c++ Subject: Re: mutexes try_lock noexcept issue Date: Tue, 3 Jan 2012 13:01:30 -0800 (PST) Organization: Roundhouse Consulting, Ltd. Lines: 31 Sender: std-cpp-request@vandevoorde.com Approved: stephen.clamage@oracle.com Message-ID: <2012010311540476770-pete@versatilecodingcom> References: NNTP-Posting-Host: 2oZfvE7CbglWnqzMP4tqGpEk5dfiTflRtKmYLS5y1AA= Content-Type: text/plain; charset=iso-8859-1; format=flowed X-Trace: news.albasani.net C+QMJj+t5IrC4Y+LbNLWP5cOqTFtrhXBHI0+hRIHcYJWZQVthzaEk9HkizEb+DGMQwuKUevbOQCL/81wFXMYbQ== X-Complaints-To: abuse@albasani.net NNTP-Posting-Date: Tue, 3 Jan 2012 21:06:56 +0000 (UTC) X-Mailer: Perl5 Mail::Internet v2.05 X-Submission-Address: std-cpp-submit@vandevoorde.com Cancel-Lock: sha1:orhV+ayjhkaPH4l7sRiZaQJesAI= X-Original-Date: Tue, 3 Jan 2012 11:54:04 -0500 Xref: x330-a1.tempe.blueboxinc.net comp.std.c++:404 On 2012-01-01 22:26:47 +0000, viboes said: > In 30.4.1.2.2 Class recursive_mutex [thread.mutex.recursive] > > try_lock is declared as noexcept > > bool try_lock() noexcept; > > but 30.4.1.2.1 Class mutex declare it without noexcept > bool try_lock(); > > The same applies for timed_mutex and recursive_timed_mutex. > > Shouldn't both be coherent. When could try_lock throw an exception? > If the mutex is already owned by the calling thread, the behavior of a call to try_lock() is undefined. One possibility is to throw an exception. For a recursive mutex, the behavior is well defined. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book) [ comp.std.c++ is moderated. To submit articles, try posting with your ] [ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]