Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
thallium
Commits
066acc19
Commit
066acc19
authored
Jun 12, 2018
by
Matthieu Dorier
Browse files
added rwlock class
parent
6c0cd8a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
include/thallium/rwlock.hpp
0 → 100644
View file @
066acc19
/*
* Copyright (c) 2017 UChicago Argonne, LLC
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __THALLIUM_RWLOCK_HPP
#define __THALLIUM_RWLOCK_HPP
#include
<abt.h>
namespace
thallium
{
/**
* @brief The rwlock class wraps and managed an ABT_rwlock.
*/
class
rwlock
{
ABT_rwlock
m_lock
;
public:
/**
* @brief Native handle type.
*/
typedef
ABT_rwlock
native_handle_type
;
/**
* @brief Constructor.
*/
explicit
rwlock
()
{
ABT_rwlock_create
(
&
m_lock
);
}
/**
* @brief Copy constructor is deleted.
*/
rwlock
(
const
rwlock
&
)
=
delete
;
/**
* @brief Move constructor.
*/
rwlock
(
rwlock
&&
other
)
{
m_lock
=
other
.
m_lock
;
other
.
m_lock
=
ABT_RWLOCK_NULL
;
}
/**
* @brief Copy assignment operator is deleted.
*/
rwlock
&
operator
=
(
const
rwlock
&
)
=
delete
;
/**
* @brief Move assignment operator.
*/
rwlock
&
operator
=
(
rwlock
&&
other
)
{
if
(
this
==
&
other
)
return
*
this
;
ABT_rwlock_free
(
&
m_lock
);
m_lock
=
other
.
m_lock
;
other
.
m_lock
=
ABT_RWLOCK_NULL
;
}
/**
* @brief Destructor.
*/
~
rwlock
()
noexcept
{
ABT_rwlock_free
(
&
m_lock
);
}
/**
* @brief Lock for reading.
*/
void
rdlock
()
noexcept
{
ABT_rwlock_rdlock
(
m_lock
);
}
/**
* @brief Lock for writing.
*/
void
wrlock
()
noexcept
{
ABT_rwlock_wrlock
(
m_lock
);
}
/**
* @brief Unlock.
*/
void
unlock
()
noexcept
{
ABT_rwlock_unlock
(
m_lock
);
}
/**
* @brief Get the underlying native handle.
*
* @return the underlying native handle.
*/
native_handle_type
native_handle
()
const
noexcept
{
return
m_lock
;
}
};
}
#endif
/* end of include guard */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment