Commit 909c4644 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

added noexcept where relevant

parent b92c6d07
......@@ -45,7 +45,7 @@ class async_response {
* @param ignore_resp whether response should be ignored.
*/
async_response(margo_request req, std::weak_ptr<detail::engine_impl> e,
hg_handle_t handle, bool ignore_resp)
hg_handle_t handle, bool ignore_resp) noexcept
: m_request(req)
, m_engine_impl(std::move(e))
, m_handle(handle)
......@@ -64,7 +64,7 @@ class async_response {
*
* @param other async_response to move from.
*/
async_response(async_response&& other)
async_response(async_response&& other) noexcept
: m_request(other.m_request)
, m_engine_impl(std::move(other.m_engine_impl))
, m_handle(other.m_handle)
......@@ -82,7 +82,7 @@ class async_response {
* @brief Move-assignment operator. Will invalidate
* the moved-from object.
*/
async_response& operator=(async_response&& other) {
async_response& operator=(async_response&& other) noexcept {
if(this == &other)
return *this;
if(m_handle != HG_HANDLE_NULL)
......@@ -99,7 +99,7 @@ class async_response {
/**
* @brief Destructor.
*/
~async_response() {
~async_response() noexcept {
if(m_handle != HG_HANDLE_NULL)
margo_destroy(m_handle);
}
......
......@@ -92,7 +92,7 @@ class barrier {
*
* @param other barrier object to move from.
*/
barrier(barrier&& other)
barrier(barrier&& other) noexcept
: m_barrier(other.m_barrier) {
other.m_barrier = ABT_BARRIER_NULL;
}
......@@ -100,7 +100,7 @@ class barrier {
/**
* @brief Destructor.
*/
~barrier() {
~barrier() noexcept {
if(m_barrier != ABT_BARRIER_NULL)
ABT_barrier_free(&m_barrier);
}
......
......@@ -46,7 +46,7 @@ class bulk {
* @param local Whether the bulk handle referes to memory that is
* local to this process.
*/
bulk(std::weak_ptr<detail::engine_impl> e, hg_bulk_t b, bool local)
bulk(std::weak_ptr<detail::engine_impl> e, hg_bulk_t b, bool local) noexcept
: m_engine_impl(std::move(e))
, m_bulk(b)
, m_is_local(local) {}
......@@ -58,8 +58,8 @@ class bulk {
class bulk_segment {
friend class remote_bulk;
std::size_t m_offset;
std::size_t m_size;
const std::size_t m_offset;
const std::size_t m_size;
const bulk& m_bulk;
public:
......@@ -70,7 +70,7 @@ class bulk {
* @param b Reference to the bulk object from which the segment is
* taken.
*/
bulk_segment(const bulk& b)
bulk_segment(const bulk& b) noexcept
: m_offset(0)
, m_size(b.size())
, m_bulk(b) {}
......@@ -83,7 +83,7 @@ class bulk {
* @param offset Offset at which the segment starts.
* @param size Size of the segment.
*/
bulk_segment(const bulk& b, std::size_t offset, std::size_t size)
bulk_segment(const bulk& b, std::size_t offset, std::size_t size) noexcept
: m_offset(offset)
, m_size(size)
, m_bulk(b) {}
......@@ -91,27 +91,27 @@ class bulk {
/**
* @brief Copy constructor is deleted.
*/
bulk_segment(const bulk_segment&) = default;
bulk_segment(const bulk_segment&) noexcept = default;
/**
* @brief Move constructor is default.
*/
bulk_segment(bulk_segment&&) = default;
bulk_segment(bulk_segment&&) noexcept = default;
/**
* @brief Copy assignment operator is default.
*/
bulk_segment& operator=(const bulk_segment&) = default;
bulk_segment& operator=(const bulk_segment&) noexcept = delete;
/**
* @brief Move assignment operator is default.
*/
bulk_segment& operator=(bulk_segment&&) = default;
bulk_segment& operator=(bulk_segment&&) noexcept = delete;
/**
* @brief Destructor is default.
*/
~bulk_segment() = default;
~bulk_segment() noexcept = default;
/**
* @brief Associates the bulk segment with an endpoint to represent
......@@ -121,7 +121,7 @@ class bulk {
*
* @return a remote_bulk object.
*/
remote_bulk on(const endpoint& ep) const;
remote_bulk on(const endpoint& ep) const noexcept;
/**
* @brief Pushes data from the left operand (bulk_segment)
......@@ -155,7 +155,7 @@ class bulk {
*
* @return a new bulk_segment object.
*/
bulk_segment select(std::size_t offset, std::size_t size) const {
bulk_segment select(std::size_t offset, std::size_t size) const noexcept {
std::size_t effective_size =
offset + size > m_size ? m_size - offset : size;
return bulk_segment(m_bulk, m_offset + offset, effective_size);
......@@ -165,7 +165,7 @@ class bulk {
* @see bulk_segment::select.
*/
inline bulk_segment operator()(std::size_t offset,
std::size_t size) const {
std::size_t size) const noexcept {
return select(offset, size);
}
};
......@@ -175,7 +175,7 @@ class bulk {
* @brief Default constructor, defined so that one can have a bulk
* object as class member and associate it later with an actual bulk.
*/
bulk()
bulk() noexcept
: m_engine_impl()
, m_bulk(HG_BULK_NULL)
, m_is_local(false) {}
......@@ -196,7 +196,7 @@ class bulk {
/**
* @brief Move constructor.
*/
bulk(bulk&& other)
bulk(bulk&& other) noexcept
: m_engine_impl(std::move(other.m_engine_impl))
, m_bulk(other.m_bulk)
, m_is_local(other.m_is_local) {
......@@ -243,7 +243,7 @@ class bulk {
/**
* @brief Destructor.
*/
~bulk() {
~bulk() noexcept {
if(m_bulk != HG_BULK_NULL) {
hg_return_t ret = margo_bulk_free(m_bulk);
MARGO_ASSERT_TERMINATE(ret, margo_bulk_free, -1);
......@@ -255,7 +255,7 @@ class bulk {
*
* @return size of data exposed by the bulk object.
*/
std::size_t size() const {
std::size_t size() const noexcept {
if(m_bulk != HG_BULK_NULL)
return margo_bulk_get_size(m_bulk);
else
......@@ -267,7 +267,7 @@ class bulk {
*
* @return true if the bulk handle is null, false otherwise.
*/
bool is_null() const { return m_bulk == HG_BULK_NULL; }
bool is_null() const noexcept { return m_bulk == HG_BULK_NULL; }
/**
* @brief Builds a remote_bulk object by associating it with an endpoint.
......@@ -276,7 +276,7 @@ class bulk {
*
* @return a remote_bulk instance.
*/
remote_bulk on(const endpoint& ep) const;
remote_bulk on(const endpoint& ep) const noexcept;
/**
* @brief Creates a bulk_segment object by selecting a given portion
......@@ -287,12 +287,12 @@ class bulk {
*
* @return a bulk_segment object.
*/
bulk_segment select(std::size_t offset, std::size_t size) const;
bulk_segment select(std::size_t offset, std::size_t size) const noexcept;
/**
* @see bulk::select
*/
bulk_segment operator()(std::size_t offset, std::size_t size) const;
bulk_segment operator()(std::size_t offset, std::size_t size) const noexcept;
/**
* @brief Pushes data from the left operand (entire bulk object)
......@@ -327,7 +327,7 @@ class bulk {
*
* @return The underlying hg_bulk_t handle.
*/
hg_bulk_t get_bulk(bool copy = false) const;
hg_bulk_t get_bulk(bool copy = false) const noexcept;
/**
* @brief Function that serializes a bulk object into/from an archive.
......@@ -356,26 +356,26 @@ class bulk {
namespace thallium {
inline hg_bulk_t bulk::get_bulk(bool copy) const {
inline hg_bulk_t bulk::get_bulk(bool copy) const noexcept {
if(copy && m_bulk != HG_BULK_NULL)
margo_bulk_ref_incr(m_bulk);
return m_bulk;
}
inline bulk::bulk_segment bulk::select(std::size_t offset, std::size_t size) const {
inline bulk::bulk_segment bulk::select(std::size_t offset, std::size_t size) const noexcept {
return bulk_segment(*this, offset, size);
}
inline bulk::bulk_segment bulk::operator()(std::size_t offset,
std::size_t size) const {
std::size_t size) const noexcept {
return select(offset, size);
}
inline remote_bulk bulk::bulk_segment::on(const endpoint& ep) const {
inline remote_bulk bulk::bulk_segment::on(const endpoint& ep) const noexcept {
return remote_bulk(*this, ep);
}
inline remote_bulk bulk::on(const endpoint& ep) const {
inline remote_bulk bulk::on(const endpoint& ep) const noexcept {
return remote_bulk(*this, ep);
}
......
......@@ -192,7 +192,7 @@ class callable_remote_procedure {
/**
* @brief Move-constructor.
*/
callable_remote_procedure(callable_remote_procedure&& other) {
callable_remote_procedure(callable_remote_procedure&& other) noexcept {
m_handle = other.m_handle;
other.m_handle = HG_HANDLE_NULL;
}
......
......@@ -64,7 +64,7 @@ class condition_variable {
/**
* @brief Destructor.
*/
~condition_variable() {
~condition_variable() noexcept {
if(m_cond != ABT_COND_NULL)
ABT_cond_free(&m_cond);
}
......@@ -100,7 +100,7 @@ class condition_variable {
* @brief Move constructor. This function will invalidate
* the passed condition_variable.
*/
condition_variable(condition_variable&& other)
condition_variable(condition_variable&& other) noexcept
: m_cond(other.m_cond) {
other.m_cond = ABT_COND_NULL;
}
......@@ -133,7 +133,7 @@ class condition_variable {
/**
* @brief Notify one waiter.
*/
void notify_one() { ABT_cond_signal(m_cond); }
void notify_one() { TL_CV_ASSERT(ABT_cond_signal(m_cond)); }
/**
* @brief Notify all waiters.
......
......@@ -42,7 +42,7 @@ class endpoint {
std::weak_ptr<detail::engine_impl> m_engine_impl;
hg_addr_t m_addr;
endpoint(std::weak_ptr<detail::engine_impl> e, hg_addr_t addr)
endpoint(std::weak_ptr<detail::engine_impl> e, hg_addr_t addr) noexcept
: m_engine_impl(std::move(e))
, m_addr(addr) {}
......@@ -60,7 +60,7 @@ class endpoint {
* @brief Default constructor defined so that endpoints can
* be member of other objects and assigned later.
*/
endpoint()
endpoint() noexcept
: m_engine_impl()
, m_addr(HG_ADDR_NULL) {}
......@@ -72,7 +72,7 @@ class endpoint {
/**
* @brief Move constructor.
*/
endpoint(endpoint&& other)
endpoint(endpoint&& other) noexcept
: m_engine_impl(other.m_engine_impl)
, m_addr(other.m_addr) {
other.m_engine_impl.reset();
......@@ -106,7 +106,7 @@ class endpoint {
*
* @return true if the endpoint is a null address.
*/
bool is_null() const { return m_addr == HG_ADDR_NULL; }
bool is_null() const noexcept { return m_addr == HG_ADDR_NULL; }
/**
* @brief Returns the underlying Mercury address.
......@@ -155,7 +155,8 @@ inline endpoint::endpoint(const engine& e, hg_addr_t addr, bool take_ownership)
if(take_ownership) {
m_addr = addr;
} else {
margo_addr_dup(e.m_impl->m_mid, addr, &m_addr);
hg_return_t ret = margo_addr_dup(e.m_impl->m_mid, addr, &m_addr);
MARGO_ASSERT(ret, margo_addr_dup);
}
}
......
......@@ -91,17 +91,17 @@ class engine {
*
* @param data pointer to the data to free (instance of rpc_callback_data).
*/
static void free_rpc_callback_data(void* data) {
static void free_rpc_callback_data(void* data) noexcept {
rpc_callback_data* cb_data = (rpc_callback_data*)data;
delete cb_data;
}
static void on_engine_finalize_cb(void* arg) {
static void on_engine_finalize_cb(void* arg) noexcept {
auto e = static_cast<detail::engine_impl*>(arg);
e->m_finalize_called = true;
}
static void on_engine_prefinalize_cb(void* arg) {
static void on_engine_prefinalize_cb(void* arg) noexcept {
auto e = static_cast<detail::engine_impl*>(arg);
(void)e; // This callback does nothing for now
}
......@@ -157,7 +157,7 @@ class engine {
*
* @param mid Margo instance.
*/
engine(margo_instance_id mid)
engine(margo_instance_id mid) noexcept
: m_impl(std::make_shared<detail::engine_impl>()) {
m_impl->m_mid = mid;
m_impl->m_owns_mid = false;
......
......@@ -207,7 +207,7 @@ template <> class eventual<void> {
/**
* @brief Move constructor.
*/
eventual(eventual&& other)
eventual(eventual&& other) noexcept
: m_eventual(other.m_eventual) {
other.m_eventual = ABT_EVENTUAL_NULL;
}
......
......@@ -110,7 +110,7 @@ template <typename T> class future {
/**
* @brief Move constructor.
*/
future(future&& other)
future(future&& other) noexcept
: m_num_compartments(other.m_num_compartments)
, m_future(other.m_future) {
other.m_future = ABT_FUTURE_NULL;
......
......@@ -89,7 +89,7 @@ class mutex {
/**
* @brief Move constructor.
*/
mutex(mutex&& other) {
mutex(mutex&& other) noexcept {
m_mutex = other.m_mutex;
other.m_mutex = ABT_MUTEX_NULL;
}
......
......@@ -205,13 +205,13 @@ class pool {
*
* @param p existing ABT_pool handle. May be null.
*/
explicit pool(ABT_pool p)
explicit pool(ABT_pool p) noexcept
: m_pool(p) {}
/**
* @brief Default constructor handles a null pool.
*/
pool()
pool() noexcept
: m_pool(ABT_POOL_NULL) {}
/**
......@@ -339,7 +339,7 @@ class pool {
/**
* @brief Move constructor.
*/
pool(pool&& other)
pool(pool&& other) noexcept
: m_pool(other.m_pool) {
other.m_pool = ABT_POOL_NULL;
}
......@@ -352,7 +352,7 @@ class pool {
/**
* @brief Move assignment operator.
*/
pool& operator=(pool&& other) {
pool& operator=(pool&& other) noexcept {
if(this == &other)
return *this;
m_pool = other.m_pool;
......@@ -370,12 +370,12 @@ class pool {
*
* @return true if the pool handle is null, false otherwise.
*/
bool is_null() const { return m_pool == ABT_POOL_NULL; }
bool is_null() const noexcept { return m_pool == ABT_POOL_NULL; }
/**
* @brief Returns true if the pool handle is not null.
*/
operator bool() const { return !is_null(); }
operator bool() const noexcept { return !is_null(); }
/**
* @brief Get the access type of the pool.
......
......@@ -66,7 +66,7 @@ class request {
/**
* @brief Move constructor.
*/
request(request&& other)
request(request&& other) noexcept
: m_engine_impl(std::move(other.m_engine_impl))
, m_handle(other.m_handle)
, m_disable_response(other.m_disable_response) {
......@@ -93,7 +93,7 @@ class request {
/**
* @brief Move-assignment operator.
*/
request& operator=(request&& other) {
request& operator=(request&& other) noexcept {
if(m_handle == other.m_handle)
return *this;
margo_destroy(m_handle);
......
......@@ -130,7 +130,7 @@ class task {
* moved from will be invalidated if different from
* the object moved to.
*/
task& operator=(task&& other) {
task& operator=(task&& other) noexcept {
if(this == &other)
return *this;
m_task = other.m_task;
......@@ -142,7 +142,7 @@ class task {
* @brief Move constructor. The object moved from will
* be invalidated.
*/
task(task&& other)
task(task&& other) noexcept
: m_task(other.m_task) {
other.m_task = ABT_TASK_NULL;
}
......
......@@ -254,7 +254,7 @@ class thread {
/**
* @brief Default constructor.
*/
thread()
thread() noexcept
: m_thread(ABT_THREAD_NULL) {}
/**
......@@ -262,7 +262,7 @@ class thread {
*
* @param t ABT_thread handle.
*/
explicit thread(ABT_thread t)
explicit thread(ABT_thread t) noexcept
: m_thread(t) {}
/**
......@@ -280,7 +280,7 @@ class thread {
* moved from will be invalidated if different from
* the object moved to.
*/
thread& operator=(thread&& other) {
thread& operator=(thread&& other) noexcept {
if(this == &other)
return *this;
m_thread = other.m_thread;
......@@ -292,7 +292,7 @@ class thread {
* @brief Move constructor. The object moved from will
* be invalidated.
*/
thread(thread&& other) {
thread(thread&& other) noexcept {
m_thread = other.m_thread;
other.m_thread = ABT_THREAD_NULL;
}
......@@ -319,7 +319,7 @@ class thread {
*
* @return the native handle of this thread.
*/
ABT_thread native_handle() const { return m_thread; }
ABT_thread native_handle() const noexcept { return m_thread; }
/**
* @brief Get the id of this thread.
......
......@@ -82,7 +82,7 @@ class timer {
*
* @return the native handle.
*/
native_handle_type native_handle() const { return m_timer; }
native_handle_type native_handle() const noexcept { return m_timer; }
/**
* @brief Constructor.
......@@ -107,7 +107,7 @@ class timer {
/**
* @brief Move constructor.
*/
timer(timer&& other)
timer(timer&& other) noexcept
: m_timer(other.m_timer) {
other.m_timer = ABT_TIMER_NULL;
}
......
......@@ -89,7 +89,7 @@ class xstream {
*
* @return the native handle.
*/
native_handle_type native_handle() const { return m_xstream; }
native_handle_type native_handle() const noexcept { return m_xstream; }
/**
* @brief Creates a managed xstream object with a
......@@ -178,19 +178,19 @@ class xstream {
/**
* @brief Default constructor. Does NOT create an ES, but a null handle.
*/
xstream()
xstream() noexcept
: m_xstream(ABT_XSTREAM_NULL) {}
/**
* @brief Copy-constructor.
*/
xstream(const xstream& other) = default;
xstream(const xstream& other) noexcept = default;
/**
* @brief Move-constructor. Will invalidate
* the moved-from xstream instance.
*/
xstream(xstream&& other)
xstream(xstream&& other) noexcept
: m_xstream(other.m_xstream) {
other.m_xstream = ABT_XSTREAM_NULL;
}
......@@ -203,7 +203,7 @@ class xstream {
/**
* @brief Move-assignment operator.
*/
xstream& operator=(xstream&& other) {
xstream& operator=(xstream&& other) noexcept {
if(&other == this)
return *this;
m_xstream = other.m_xstream;
......@@ -345,14 +345,14 @@ class xstream {
*
* @return true if the ES is null.
*/
bool is_null() const { return m_xstream == ABT_XSTREAM_NULL; }
bool is_null() const noexcept { return m_xstream == ABT_XSTREAM_NULL; }
/**
* @brief Checks whether the ES is not null.
*
* @return true if the ES is not null, false otherwise.
*/
operator bool() const { return !is_null(); }
operator bool() const noexcept { return !is_null(); }
/**
* @brief Sets the scheduler that the ES should use.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment