Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Alexander Terekhov<terekhov@web.de> |
|---|---|
| Newsgroups | comp.std.c++ |
| Subject | Re: mutexes try_lock noexcept issue |
| Date | 2012-01-11 09:58 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <4F0C89DE.EC72DEB3@web.de> (permalink) |
| References | <cf2b78da-6d9e-4163-bb7e-de5b74abbeca@m10g2000vbc.googlegroups.com> <2012010311540476770-pete@versatilecodingcom> |
[ Moderator's note: The posting 'bot was down for a few days. -sdc ] Pete Becker wrote: > > 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. http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html "ERRORS The pthread_mutex_lock() and pthread_mutex_trylock() functions shall fail if: [EAGAIN] The mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded." How is that error is supposed to be reported with bool try_lock() noexcept given that false bool reflects "The pthread_mutex_trylock() function shall fail if: [EBUSY] The mutex could not be acquired because it was already locked. " <?> regards, alexander. -- [ 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 ]
Back to comp.std.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
mutexes try_lock noexcept issue viboes<vicente.botet@wanadoo.fr> - 2012-01-01 14:26 -0800
Re: mutexes try_lock noexcept issue Pete Becker<pete@versatilecoding.com> - 2012-01-03 13:01 -0800
Re: mutexes try_lock noexcept issue Alexander Terekhov<terekhov@web.de> - 2012-01-11 09:58 -0800
Re: mutexes try_lock noexcept issue Daniel Krügler<daniel.kruegler@googlemail.com> - 2012-01-14 17:16 -0800
csiph-web