Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyFastANI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Larralde
PyFastANI
Commits
c3ce403d
Commit
c3ce403d
authored
2 years ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Add an `atomic_vector` wrapper for `vector` where `push_back` is thread-safe
parent
8558fda7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyfastani/_atomic_vector.hpp
+21
-0
21 additions, 0 deletions
pyfastani/_atomic_vector.hpp
pyfastani/_atomic_vector.pxd
+5
-0
5 additions, 0 deletions
pyfastani/_atomic_vector.pxd
with
26 additions
and
0 deletions
pyfastani/_atomic_vector.hpp
0 → 100644
+
21
−
0
View file @
c3ce403d
#ifndef _SAFEVEC_HPP
#define _SAFEVEC_HPP
#include
<mutex>
#include
<vector>
template
<
class
T
>
class
atomic_vector
:
public
std
::
vector
<
T
>
{
protected:
std
::
mutex
mutex
;
public:
atomic_vector
()
:
std
::
vector
<
T
>
(),
mutex
()
{}
void
push_back
(
const
T
&
val
)
{
mutex
.
lock
();
std
::
vector
<
T
>::
push_back
(
val
);
mutex
.
unlock
();
}
};
#endif
This diff is collapsed.
Click to expand it.
pyfastani/_atomic_vector.pxd
0 → 100644
+
5
−
0
View file @
c3ce403d
from
libcpp.vector
cimport
vector
cdef
extern
from
"
_atomic_vector.hpp
"
nogil
:
cdef
cppclass
atomic_vector
[
T
](
vector
[
T
]):
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment