Skip to content

Commit

Permalink
Improve noexcept guarantee
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcrimsontianyu committed Jan 21, 2025
1 parent 19a6ef1 commit dacde41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 12 additions & 9 deletions cpp/src/file_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,18 @@ bool FileHandle::closed() const noexcept { return !_initialized; }

void FileHandle::close() noexcept
{
if (closed()) { return; }

if (!is_compat_mode_preferred()) { cuFileAPI::instance().HandleDeregister(_handle); }
_compat_mode = CompatMode::AUTO;
::close(_fd_direct_off);
if (_fd_direct_on != -1) { ::close(_fd_direct_on); }
_fd_direct_on = -1;
_fd_direct_off = -1;
_initialized = false;
try {
if (closed()) { return; }

if (!is_compat_mode_preferred()) { cuFileAPI::instance().HandleDeregister(_handle); }
_compat_mode = CompatMode::AUTO;
::close(_fd_direct_off);
if (_fd_direct_on != -1) { ::close(_fd_direct_on); }
_fd_direct_on = -1;
_fd_direct_off = -1;
_initialized = false;
} catch (...) {
}
}

CUfileHandle_t FileHandle::handle()
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/shim/cufile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool is_cufile_library_available() noexcept
{
try {
cuFileAPI::instance();
} catch (const std::runtime_error&) {
} catch (...) {
return false;
}
return true;
Expand All @@ -144,7 +144,7 @@ int cufile_version() noexcept
{
try {
return cuFileAPI::instance().version;
} catch (std::runtime_error const&) {
} catch (...) {
return 0;
}
}
Expand Down

0 comments on commit dacde41

Please sign in to comment.