From 7f77e72dcaa3bfe9c684f92bbd84f9ecf4348007 Mon Sep 17 00:00:00 2001 From: Cody Licorish Date: Mon, 18 May 2020 13:14:06 -0500 Subject: [PATCH] Change `acquire` and `release` to noexcept This change allows developers to more easily use the default implementations of the `mmapio_i` interface in noexcept contexts. The default implementations report their errors through `errno`. --- mmapio.cpp | 16 ++++++++-------- mmapio.hpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mmapio.cpp b/mmapio.cpp index 7d24e18..c664465 100644 --- a/mmapio.cpp +++ b/mmapio.cpp @@ -100,13 +100,13 @@ namespace mmapio { * \brief Acquire a lock to the space. * \return pointer to locked space on success, NULL otherwise */ - void* acquire(void) override; + void* acquire(void) noexcept override; /** * \brief Release a lock of the space. * \param p pointer of region to release */ - void release(void* p) override; + void release(void* p) noexcept override; /** * \brief Check the length of the mapped area. @@ -198,13 +198,13 @@ namespace mmapio { * \brief Acquire a lock to the space. * \return pointer to locked space on success, NULL otherwise */ - void* acquire(void) override; + void* acquire(void) noexcept override; /** * \brief Release a lock of the space. * \param p pointer of region to release */ - void release(void* p) override; + void release(void* p) noexcept override; /** * \brief Check the length of the mapped area. @@ -601,11 +601,11 @@ namespace mmapio { return; } - void* mmapio_unix::acquire(void) { + void* mmapio_unix::acquire(void) noexcept { return static_cast(this->ptr)+this->shift; } - void mmapio_unix::release(void* p) { + void mmapio_unix::release(void* p) noexcept { return; } @@ -747,11 +747,11 @@ namespace mmapio { return; } - void* mmapio_win32::acquire(void) { + void* mmapio_win32::acquire(void) noexcept { return static_cast(this->ptr)+this->shift; } - void mmapio_win32::release(void* p) { + void mmapio_win32::release(void* p) noexcept { return; } diff --git a/mmapio.hpp b/mmapio.hpp index 141fab6..e50e5b9 100644 --- a/mmapio.hpp +++ b/mmapio.hpp @@ -83,13 +83,13 @@ namespace mmapio { * \brief Acquire a lock to the space. * \return pointer to locked space on success, NULL otherwise */ - virtual void* acquire(void) = 0; + virtual void* acquire(void) noexcept = 0; /** * \brief Release a lock of the space. * \param p pointer of region to release */ - virtual void release(void* p) = 0; + virtual void release(void* p) noexcept = 0; /** * \brief Check the length of the mapped area.