diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-12 11:32:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-12 12:49:35 +0200 |
commit | a3c294e6ad33c43b7c515b9bf543aa4bb27a7d51 (patch) | |
tree | 0a7d29936797cae962d4147a1eea014778032967 /include | |
parent | 05144427303b2aa09108eeb03606fa66da275d2b (diff) |
convert ReadWriteGuardMode to scoped enum
Change-Id: I21ae815d5bbd7b39cd690168738c21925558585e
Reviewed-on: https://gerrit.libreoffice.org/36452
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/unotools/readwritemutexguard.hxx | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/include/unotools/readwritemutexguard.hxx b/include/unotools/readwritemutexguard.hxx index 94767024a911..b11ea8a1e405 100644 --- a/include/unotools/readwritemutexguard.hxx +++ b/include/unotools/readwritemutexguard.hxx @@ -21,6 +21,17 @@ #define INCLUDED_UNOTOOLS_READWRITEMUTEXGUARD_HXX #include <osl/mutex.hxx> +#include <o3tl/typed_flags_set.hxx> + +enum class ReadWriteGuardMode { + ReadOnly = 0x00, + Write = 0x01, + CriticalChange = 0x02 | Write, + BlockCritical = 0x04, // only a block, not a read, exclusive flag! +}; +namespace o3tl { + template<> struct typed_flags<ReadWriteGuardMode> : is_typed_flags<ReadWriteGuardMode, 0x7> {}; +} namespace utl { @@ -41,12 +52,6 @@ public: {} }; -namespace ReadWriteGuardMode { -const sal_Int32 nWrite = 0x01; -const sal_Int32 nCriticalChange = 0x02 | nWrite; -const sal_Int32 nBlockCritical = 0x04; // only a block, not a read, exclusive flag! -} - /** Enable multiple threads to read simultaneously, but a write blocks all other reads and writes, and a read blocks any write. Used in I18N wrappers to be able to maintain a single instance of a wrapper @@ -67,11 +72,11 @@ const sal_Int32 nBlockCritical = 0x04; // only a block, not a read, exclusi class ReadWriteGuard { ReadWriteMutex& rMutex; - sal_Int32 nMode; + ReadWriteGuardMode nMode; public: ReadWriteGuard( ReadWriteMutex& rMutex, - sal_Int32 nRequestMode = 0 // read only + ReadWriteGuardMode nRequestMode = ReadWriteGuardMode::ReadOnly // read only ); ~ReadWriteGuard(); |