Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Fischer
emper
Commits
67f93b95
Commit
67f93b95
authored
3 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
[LockedSet] Add insertAndGetSize()
parent
379ea507
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
emper/lib/adt/LockedSet.hpp
+11
-2
11 additions, 2 deletions
emper/lib/adt/LockedSet.hpp
with
11 additions
and
2 deletions
emper/lib/adt/LockedSet.hpp
+
11
−
2
View file @
67f93b95
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020 Florian Fischer
// Copyright © 2020 Florian Fischer
, 2021 Florian Schmaus
#pragma once
#include
<iterator>
...
...
@@ -10,11 +10,20 @@ namespace emper::lib::adt {
template
<
class
Key
,
class
Compare
=
std
::
less
<
Key
>,
class
Allocator
=
std
::
allocator
<
Key
>>
class
LockedSet
{
public:
using
set_type
=
std
::
set
<
Key
,
Compare
,
Allocator
>
;
private:
std
::
mutex
_mutex
;
s
td
::
set
<
Key
,
Compare
,
Allocator
>
_set
;
s
et_type
_set
;
public:
auto
insertAndGetSize
(
const
Key
&
item
)
->
typename
set_type
::
size_type
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
_set
.
insert
(
item
);
return
_set
.
size
();
}
auto
insert
(
const
Key
&
item
)
->
std
::
pair
<
typename
std
::
set
<
Key
,
Compare
,
Allocator
>::
iterator
,
bool
>
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
_mutex
);
...
...
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