Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
thallium
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
thallium
Commits
066acc19
Commit
066acc19
authored
Jun 12, 2018
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added rwlock class
parent
6c0cd8a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
0 deletions
+103
-0
include/thallium/rwlock.hpp
include/thallium/rwlock.hpp
+103
-0
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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