[Libreoffice] Mutex(Guard) ignores failure to create/acquire Mutex
Lionel Elie Mamane
lionel at mamane.lu
Wed Aug 17 22:12:39 PDT 2011
Hi,
I noticed that Mutex(Guard) C++ helper classes silently ignores
failures to create / acquire / release / destroy a mutex, which seems
rather worrying: if one puts a mutex acquire, it means the rest of the
code should not execute if the mutex was not acquired, lest subtle
bugs crop up (corruption of thread-shared variables and all that).
So my natural tendency would be to make create (in Mutex::Mutex) and
acquire (in Guard::Guard, ResettableGuard::reset, etc) errors "hard"
errors by throwing a RuntimeException; that is, obviously, unless the
file is compiled without exception support, in which case... we
fallback to the current behaviour? Or rather an OSL_FAIL?
Release errors in a MutexGuard destructor cannot be an exception, so
an OSL_FAIL.
The Mutex/MutexGuard classes are implemented 100% in header file, so
they can adapt to the compilation options of the file they are used
in, and it seems the LO build system nicely defines EXCEPTIONS_ON or
EXCEPTIONS_OFF to give that information.
Opinions? Any reason this is a bad idea?
--
Lionel
More information about the LibreOffice
mailing list