Skip to content

Commit

Permalink
Change acquire and release to noexcept
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
codylico committed May 18, 2020
1 parent 93829e3 commit 7f77e72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions mmapio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -601,11 +601,11 @@ namespace mmapio {
return;
}

void* mmapio_unix::acquire(void) {
void* mmapio_unix::acquire(void) noexcept {
return static_cast<unsigned char*>(this->ptr)+this->shift;
}

void mmapio_unix::release(void* p) {
void mmapio_unix::release(void* p) noexcept {
return;
}

Expand Down Expand Up @@ -747,11 +747,11 @@ namespace mmapio {
return;
}

void* mmapio_win32::acquire(void) {
void* mmapio_win32::acquire(void) noexcept {
return static_cast<unsigned char*>(this->ptr)+this->shift;
}

void mmapio_win32::release(void* p) {
void mmapio_win32::release(void* p) noexcept {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions mmapio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7f77e72

Please sign in to comment.