summaryrefslogtreecommitdiff
path: root/src/cache.cpp
diff options
context:
space:
mode:
authorIvan Shapovalov <intelfx@intelfx.name>2016-10-22 05:14:19 +0300
committerIvan Shapovalov <intelfx@intelfx.name>2016-10-22 08:45:25 +0300
commitb98af44fcf89b9946e1de438b1f5527e6bf28905 (patch)
treefbd5ec2ab1e418830b88e5de42279845911ea0da /src/cache.cpp
parent5d03d48f7aaf38d3b28bad612638d2d9db8ebee0 (diff)
treewide: use C++ exceptions properly
Since the codebase is designed around proper C++ idioms such as RAII, it makes sense to only use C++ exceptions internally instead of mixing exceptions and error codes. The exceptions are now caught at top level to preserve compatibility with the existing error code-based API. Note that we deliberately do not catch C++ runtime errors (such as `std::bad_alloc`) nor logic errors (aka failed assertions) because no actual handling can ever happen for such errors. However, in the C interface we do catch _all_ exceptions (...) and convert them into a wild-card error code.
Diffstat (limited to 'src/cache.cpp')
-rw-r--r--src/cache.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/cache.cpp b/src/cache.cpp
index 6080f082..6786eaa2 100644
--- a/src/cache.cpp
+++ b/src/cache.cpp
@@ -57,7 +57,7 @@ const std::string& GetBinaryFromCache(const std::string &device_name, const Prec
}
}
binary_cache_mutex_.unlock();
- throw std::runtime_error("Internal CLBlast error: Expected binary in cache, but found none.");
+ throw LogicError("GetBinaryFromCache: Expected binary in cache, but found none");
}
// Queries the cache and retrieves a matching program. Assumes that the match is available, throws
@@ -75,7 +75,7 @@ const Program& GetProgramFromCache(const Context &context, const Precision &prec
}
}
program_cache_mutex_.unlock();
- throw std::runtime_error("Internal CLBlast error: Expected program in cache, but found none.");
+ throw LogicError("GetProgramFromCache: Expected program in cache, but found none");
}
// Queries the cache to see whether or not the compiled kernel is already there
@@ -109,14 +109,13 @@ bool ProgramIsInCache(const Context &context, const Precision &precision,
// =================================================================================================
// Clears the cache of stored binaries and programs
-StatusCode CacheClearAll() {
+void CacheClearAll() {
binary_cache_mutex_.lock();
binary_cache_.clear();
binary_cache_mutex_.unlock();
program_cache_mutex_.lock();
program_cache_.clear();
program_cache_mutex_.unlock();
- return StatusCode::kSuccess;
}
// =================================================================================================