Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
334b3c4b
Commit
334b3c4b
authored
Sep 30, 2019
by
Frederic De Jaeger
Committed by
Dominik Charousset
Dec 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't reimplement a thread local storage. Use the c++ keyword.
parent
0964a009
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
25 deletions
+6
-25
libcaf_core/caf/logger.hpp
libcaf_core/caf/logger.hpp
+0
-6
libcaf_core/src/logger.cpp
libcaf_core/src/logger.cpp
+6
-19
No files found.
libcaf_core/caf/logger.hpp
View file @
334b3c4b
...
@@ -352,12 +352,6 @@ private:
...
@@ -352,12 +352,6 @@ private:
// References the parent system.
// References the parent system.
actor_system
&
system_
;
actor_system
&
system_
;
// Guards aids_.
detail
::
shared_spinlock
aids_lock_
;
// Maps thread IDs to actor IDs.
std
::
unordered_map
<
std
::
thread
::
id
,
actor_id
>
aids_
;
// Identifies the thread that called `logger::start`.
// Identifies the thread that called `logger::start`.
std
::
thread
::
id
parent_thread_
;
std
::
thread
::
id
parent_thread_
;
...
...
libcaf_core/src/logger.cpp
View file @
334b3c4b
...
@@ -295,29 +295,16 @@ std::string logger::line_builder::get() const {
...
@@ -295,29 +295,16 @@ std::string logger::line_builder::get() const {
}
}
// returns the actor ID for the current thread
// returns the actor ID for the current thread
thread_local
actor_id
_currentActoId
;
actor_id
logger
::
thread_local_aid
()
{
actor_id
logger
::
thread_local_aid
()
{
shared_lock
<
detail
::
shared_spinlock
>
guard
{
aids_lock_
};
return
_currentActoId
;
auto
i
=
aids_
.
find
(
std
::
this_thread
::
get_id
());
if
(
i
!=
aids_
.
end
())
return
i
->
second
;
return
0
;
}
}
actor_id
logger
::
thread_local_aid
(
actor_id
aid
)
{
actor_id
logger
::
thread_local_aid
(
actor_id
aid
)
{
auto
tid
=
std
::
this_thread
::
get_id
();
auto
old
=
_currentActoId
;
upgrade_lock
<
detail
::
shared_spinlock
>
guard
{
aids_lock_
};
_currentActoId
=
aid
;
auto
i
=
aids_
.
find
(
tid
);
return
old
;
if
(
i
!=
aids_
.
end
())
{
// we modify it despite the shared lock because the elements themselves
// are considered thread-local
auto
res
=
i
->
second
;
i
->
second
=
aid
;
return
res
;
}
// upgrade to unique lock and insert new element
upgrade_to_unique_lock
<
detail
::
shared_spinlock
>
uguard
{
guard
};
aids_
.
emplace
(
tid
,
aid
);
return
0
;
// was empty before
}
}
void
logger
::
log
(
event
&&
x
)
{
void
logger
::
log
(
event
&&
x
)
{
...
...
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