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
921ab3c7
Unverified
Commit
921ab3c7
authored
Apr 07, 2020
by
Dominik Charousset
Committed by
GitHub
Apr 07, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1083
Make getter/setter of thread-local variable static
parents
f3203e75
69a6b5ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
26 deletions
+18
-26
libcaf_core/caf/logger.hpp
libcaf_core/caf/logger.hpp
+8
-17
libcaf_core/caf/make_actor.hpp
libcaf_core/caf/make_actor.hpp
+10
-9
No files found.
libcaf_core/caf/logger.hpp
View file @
921ab3c7
...
@@ -220,10 +220,10 @@ public:
...
@@ -220,10 +220,10 @@ public:
// -- properties -------------------------------------------------------------
// -- properties -------------------------------------------------------------
/// Returns the ID of the actor currently associated to the calling thread.
/// Returns the ID of the actor currently associated to the calling thread.
actor_id
thread_local_aid
();
static
actor_id
thread_local_aid
();
/// Associates an actor ID to the calling thread and returns the last value.
/// Associates an actor ID to the calling thread and returns the last value.
actor_id
thread_local_aid
(
actor_id
aid
);
static
actor_id
thread_local_aid
(
actor_id
aid
);
/// Returns whether the logger is configured to accept input for given
/// Returns whether the logger is configured to accept input for given
/// component and log level.
/// component and log level.
...
@@ -431,29 +431,20 @@ CAF_CORE_EXPORT bool operator==(const logger::field& x, const logger::field& y);
...
@@ -431,29 +431,20 @@ CAF_CORE_EXPORT bool operator==(const logger::field& x, const logger::field& y);
if (CAF_UNIFYN(caf_logger) != nullptr \
if (CAF_UNIFYN(caf_logger) != nullptr \
&& CAF_UNIFYN(caf_logger)->accepts(loglvl, component)) \
&& CAF_UNIFYN(caf_logger)->accepts(loglvl, component)) \
CAF_UNIFYN(caf_logger) \
CAF_UNIFYN(caf_logger) \
->log(CAF_LOG_MAKE_EVENT(
CAF_UNIFYN(caf_logger)->thread_local_aid()
, \
->log(CAF_LOG_MAKE_EVENT(
caf::logger::thread_local_aid(), component
, \
component, loglvl, message));
\
loglvl, message));
\
} while (false)
} while (false)
#define CAF_PUSH_AID(aarg) \
#define CAF_PUSH_AID(aarg) \
auto CAF_UNIFYN(caf_tmp_ptr) = caf::logger::current_logger(); \
caf::actor_id CAF_UNIFYN(caf_aid_tmp) = caf::logger::thread_local_aid(aarg); \
caf::actor_id CAF_UNIFYN(caf_aid_tmp) = 0; \
auto CAF_UNIFYN(caf_aid_tmp_guard) = caf::detail::make_scope_guard( \
if (CAF_UNIFYN(caf_tmp_ptr)) \
[=] { caf::logger::thread_local_aid(CAF_UNIFYN(caf_aid_tmp)); })
CAF_UNIFYN(caf_aid_tmp) = CAF_UNIFYN(caf_tmp_ptr)->thread_local_aid(aarg); \
auto CAF_UNIFYN(aid_aid_tmp_guard) = caf::detail::make_scope_guard([=] { \
auto CAF_UNIFYN(caf_tmp2_ptr) = caf::logger::current_logger(); \
if (CAF_UNIFYN(caf_tmp2_ptr)) \
CAF_UNIFYN(caf_tmp2_ptr)->thread_local_aid(CAF_UNIFYN(caf_aid_tmp)); \
})
#define CAF_PUSH_AID_FROM_PTR(some_ptr) \
#define CAF_PUSH_AID_FROM_PTR(some_ptr) \
auto CAF_UNIFYN(caf_aid_ptr) = some_ptr; \
auto CAF_UNIFYN(caf_aid_ptr) = some_ptr; \
CAF_PUSH_AID(CAF_UNIFYN(caf_aid_ptr) ? CAF_UNIFYN(caf_aid_ptr)->id() : 0)
CAF_PUSH_AID(CAF_UNIFYN(caf_aid_ptr) ? CAF_UNIFYN(caf_aid_ptr)->id() : 0)
#define CAF_SET_AID(aid_arg) \
#define CAF_SET_AID(aid_arg) caf::logger::thread_local_aid(aid_arg)
(caf::logger::current_logger() \
? caf::logger::current_logger()->thread_local_aid(aid_arg) \
: 0)
#define CAF_SET_LOGGER_SYS(ptr) caf::logger::set_current_actor_system(ptr)
#define CAF_SET_LOGGER_SYS(ptr) caf::logger::set_current_actor_system(ptr)
...
...
libcaf_core/caf/make_actor.hpp
View file @
921ab3c7
...
@@ -33,22 +33,23 @@ namespace caf {
...
@@ -33,22 +33,23 @@ namespace caf {
template
<
class
T
,
class
R
=
infer_handle_from_class_t
<
T
>,
class
...
Ts
>
template
<
class
T
,
class
R
=
infer_handle_from_class_t
<
T
>,
class
...
Ts
>
R
make_actor
(
actor_id
aid
,
node_id
nid
,
actor_system
*
sys
,
Ts
&&
...
xs
)
{
R
make_actor
(
actor_id
aid
,
node_id
nid
,
actor_system
*
sys
,
Ts
&&
...
xs
)
{
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
actor_storage
<
T
>*
ptr
=
nullptr
;
if
(
logger
::
current_logger
()
->
accepts
(
CAF_LOG_LEVEL_DEBUG
,
if
(
logger
::
current_logger
()
->
accepts
(
CAF_LOG_LEVEL_DEBUG
,
CAF_LOG_FLOW_COMPONENT
))
{
CAF_LOG_FLOW_COMPONENT
))
{
std
::
string
args
;
std
::
string
args
;
args
=
deep_to_string
(
std
::
forward_as_tuple
(
xs
...));
args
=
deep_to_string
(
std
::
forward_as_tuple
(
xs
...));
ptr
actor_storage
<
T
>*
ptr
;
=
new
actor_storage
<
T
>
(
aid
,
std
::
move
(
nid
),
sys
,
std
::
forward
<
Ts
>
(
xs
)...);
{
CAF_PUSH_AID
(
aid
);
ptr
=
new
actor_storage
<
T
>
(
aid
,
std
::
move
(
nid
),
sys
,
std
::
forward
<
Ts
>
(
xs
)...);
}
CAF_LOG_SPAWN_EVENT
(
ptr
->
data
,
args
);
CAF_LOG_SPAWN_EVENT
(
ptr
->
data
,
args
);
}
else
{
return
{
&
(
ptr
->
ctrl
),
false
};
ptr
=
new
actor_storage
<
T
>
(
aid
,
std
::
move
(
nid
),
sys
,
std
::
forward
<
Ts
>
(
xs
)...);
}
}
#else
auto
ptr
=
new
actor_storage
<
T
>
(
aid
,
std
::
move
(
nid
),
sys
,
std
::
forward
<
Ts
>
(
xs
)...);
#endif
#endif
CAF_PUSH_AID
(
aid
);
auto
ptr
=
new
actor_storage
<
T
>
(
aid
,
std
::
move
(
nid
),
sys
,
std
::
forward
<
Ts
>
(
xs
)...);
return
{
&
(
ptr
->
ctrl
),
false
};
return
{
&
(
ptr
->
ctrl
),
false
};
}
}
...
...
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