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
51067802
Commit
51067802
authored
Feb 20, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Streamline `local_actor::send_impl`
parent
bbf9df7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
57 deletions
+37
-57
libcaf_core/caf/local_actor.hpp
libcaf_core/caf/local_actor.hpp
+34
-54
libcaf_core/src/local_actor.cpp
libcaf_core/src/local_actor.cpp
+3
-3
No files found.
libcaf_core/caf/local_actor.hpp
View file @
51067802
...
@@ -144,28 +144,27 @@ class local_actor : public abstract_actor {
...
@@ -144,28 +144,27 @@ class local_actor : public abstract_actor {
****************************************************************************/
****************************************************************************/
/**
/**
* Sends `{vs...} to `dest` using the priority `
prio
`.
* Sends `{vs...} to `dest` using the priority `
mp
`.
*/
*/
template
<
class
...
Vs
>
template
<
class
...
Vs
>
inline
void
send
(
message_priority
prio
,
const
channel
&
dest
,
Vs
&&
...
vs
)
{
void
send
(
message_priority
mp
,
const
channel
&
dest
,
Vs
&&
...
vs
)
{
static_assert
(
sizeof
...(
Vs
)
>
0
,
"sizeof...(Vs) == 0"
);
static_assert
(
sizeof
...(
Vs
)
>
0
,
"sizeof...(Vs) == 0"
);
fast_send
(
prio
,
dest
,
std
::
forward
<
Vs
>
(
vs
)...);
send_impl
(
mp
,
actor_cast
<
abstract_channel
*>
(
dest
)
,
std
::
forward
<
Vs
>
(
vs
)...);
}
}
/**
/**
* Sends `{vs...} to `dest` using normal priority.
* Sends `{vs...} to `dest` using normal priority.
*/
*/
template
<
class
...
Vs
>
template
<
class
...
Vs
>
inline
void
send
(
const
channel
&
dest
,
Vs
&&
...
vs
)
{
void
send
(
const
channel
&
dest
,
Vs
&&
...
vs
)
{
static_assert
(
sizeof
...(
Vs
)
>
0
,
"sizeof...(Vs) == 0"
);
send
(
message_priority
::
normal
,
dest
,
std
::
forward
<
Vs
>
(
vs
)...);
fast_send
(
message_priority
::
normal
,
dest
,
std
::
forward
<
Vs
>
(
vs
)...);
}
}
/**
/**
* Sends `{vs...} to `dest` using the priority `
prio
`.
* Sends `{vs...} to `dest` using the priority `
mp
`.
*/
*/
template
<
class
...
Ts
,
class
...
Vs
>
template
<
class
...
Ts
,
class
...
Vs
>
void
send
(
message_priority
prio
,
const
typed_actor
<
Ts
...
>&
dest
,
Vs
&&
...
vs
)
{
void
send
(
message_priority
mp
,
const
typed_actor
<
Ts
...
>&
dest
,
Vs
&&
...
vs
)
{
using
token
=
using
token
=
detail
::
type_list
<
detail
::
type_list
<
typename
detail
::
implicit_conversions
<
typename
detail
::
implicit_conversions
<
...
@@ -173,7 +172,7 @@ class local_actor : public abstract_actor {
...
@@ -173,7 +172,7 @@ class local_actor : public abstract_actor {
>::
type
...
>
;
>::
type
...
>
;
token
tk
;
token
tk
;
check_typed_input
(
dest
,
tk
);
check_typed_input
(
dest
,
tk
);
fast_send
(
prio
,
dest
,
std
::
forward
<
Vs
>
(
vs
)...);
send_impl
(
mp
,
actor_cast
<
abstract_channel
*>
(
dest
)
,
std
::
forward
<
Vs
>
(
vs
)...);
}
}
/**
/**
...
@@ -192,27 +191,19 @@ class local_actor : public abstract_actor {
...
@@ -192,27 +191,19 @@ class local_actor : public abstract_actor {
/**
/**
* Sends an exit message to `dest`.
* Sends an exit message to `dest`.
*/
*/
inline
void
send_exit
(
const
actor
&
dest
,
uint32_t
reason
)
{
template
<
class
ActorHandle
>
send_exit
(
dest
.
address
(),
reason
);
void
send_exit
(
const
ActorHandle
&
dest
,
uint32_t
reason
)
{
}
/**
* Sends an exit message to `dest`.
*/
template
<
class
...
Ts
>
void
send_exit
(
const
typed_actor
<
Ts
...
>&
dest
,
uint32_t
reason
)
{
send_exit
(
dest
.
address
(),
reason
);
send_exit
(
dest
.
address
(),
reason
);
}
}
/**
/**
* Sends a message to `dest` that is delayed by `rel_time`
* Sends a message to `dest` that is delayed by `rel_time`
* using the priority `
prio
`.
* using the priority `
mp
`.
*/
*/
template
<
class
...
Vs
>
template
<
class
...
Vs
>
void
delayed_send
(
message_priority
prio
,
const
channel
&
dest
,
void
delayed_send
(
message_priority
mp
,
const
channel
&
dest
,
const
duration
&
rtime
,
Vs
&&
...
vs
)
{
const
duration
&
rtime
,
Vs
&&
...
vs
)
{
delayed_send_impl
(
prio
,
dest
,
rtime
,
delayed_send_impl
(
mp
,
dest
,
rtime
,
make_message
(
std
::
forward
<
Vs
>
(
vs
)...));
make_message
(
std
::
forward
<
Vs
>
(
vs
)...));
}
}
/**
/**
...
@@ -403,12 +394,12 @@ class local_actor : public abstract_actor {
...
@@ -403,12 +394,12 @@ class local_actor : public abstract_actor {
// </backward_compatibility>
// </backward_compatibility>
// <backward_compatibility version="0.9">
// <backward_compatibility version="0.9">
inline
void
send_tuple
(
message_priority
prio
,
const
channel
&
whom
,
inline
void
send_tuple
(
message_priority
mp
,
const
channel
&
whom
,
message
what
)
CAF_DEPRECATED
;
message
what
)
CAF_DEPRECATED
;
inline
void
send_tuple
(
const
channel
&
whom
,
message
what
)
CAF_DEPRECATED
;
inline
void
send_tuple
(
const
channel
&
whom
,
message
what
)
CAF_DEPRECATED
;
inline
void
delayed_send_tuple
(
message_priority
prio
,
const
channel
&
whom
,
inline
void
delayed_send_tuple
(
message_priority
mp
,
const
channel
&
whom
,
const
duration
&
rtime
,
const
duration
&
rtime
,
message
data
)
CAF_DEPRECATED
;
message
data
)
CAF_DEPRECATED
;
...
@@ -477,7 +468,7 @@ class local_actor : public abstract_actor {
...
@@ -477,7 +468,7 @@ class local_actor : public abstract_actor {
void
reply_message
(
message
&&
what
);
void
reply_message
(
message
&&
what
);
void
forward_message
(
const
actor
&
new_receiver
,
message_priority
prio
);
void
forward_message
(
const
actor
&
dest
,
message_priority
mp
);
inline
bool
awaits
(
message_id
response_id
)
{
inline
bool
awaits
(
message_id
response_id
)
{
CAF_REQUIRE
(
response_id
.
is_response
());
CAF_REQUIRE
(
response_id
.
is_response
());
...
@@ -516,38 +507,23 @@ class local_actor : public abstract_actor {
...
@@ -516,38 +507,23 @@ class local_actor : public abstract_actor {
/** @endcond */
/** @endcond */
private:
private:
template
<
class
...
Vs
>
template
<
class
V
,
class
...
Vs
>
void
fast_send_impl
(
message_priority
mp
,
abstract_channel
*
dest
,
Vs
&&
...
vs
)
{
typename
std
::
enable_if
<
!
std
::
is_same
<
typename
std
::
decay
<
V
>::
type
,
message
>::
value
>::
type
send_impl
(
message_priority
mp
,
abstract_channel
*
dest
,
V
&&
v
,
Vs
&&
...
vs
)
{
if
(
!
dest
)
{
if
(
!
dest
)
{
return
;
return
;
}
}
dest
->
enqueue
(
mailbox_element
::
make_joint
(
address
(),
message_id
::
make
(
mp
),
dest
->
enqueue
(
mailbox_element
::
make_joint
(
address
(),
message_id
::
make
(
mp
),
std
::
forward
<
V
>
(
v
),
std
::
forward
<
Vs
>
(
vs
)...),
std
::
forward
<
Vs
>
(
vs
)...),
host
());
host
());
}
}
template
<
class
T
,
class
V0
,
class
...
Vs
>
void
send_impl
(
message_priority
mp
,
abstract_channel
*
dest
,
message
what
);
typename
std
::
enable_if
<
!
std
::
is_same
<
typename
std
::
decay
<
V0
>::
type
,
message
>::
value
>::
type
fast_send
(
message_priority
mp
,
const
T
&
dest
,
V0
&&
v0
,
Vs
&&
...
vs
)
{
fast_send_impl
(
mp
,
actor_cast
<
abstract_channel
*>
(
dest
),
std
::
forward
<
V0
>
(
v0
),
std
::
forward
<
Vs
>
(
vs
)...);
}
template
<
class
T
>
void
fast_send
(
message_priority
mp
,
const
T
&
dest
,
message
what
)
{
send_impl
(
mp
,
actor_cast
<
abstract_channel
*>
(
dest
),
std
::
move
(
what
));
}
void
send_impl
(
message_priority
prio
,
abstract_channel
*
dest
,
message
&&
what
);
template
<
class
T
>
void
send_impl
(
message_priority
prio
,
const
T
&
dest
,
message
&&
what
)
{
send_impl
(
prio
,
actor_cast
<
abstract_channel
*>
(
dest
),
std
::
move
(
what
));
}
void
delayed_send_impl
(
message_priority
prio
,
const
channel
&
whom
,
void
delayed_send_impl
(
message_priority
mp
,
const
channel
&
whom
,
const
duration
&
rtime
,
message
data
);
const
duration
&
rtime
,
message
data
);
std
::
function
<
void
()
>
m_sync_failure_handler
;
std
::
function
<
void
()
>
m_sync_failure_handler
;
...
@@ -561,26 +537,30 @@ class local_actor : public abstract_actor {
...
@@ -561,26 +537,30 @@ class local_actor : public abstract_actor {
using
local_actor_ptr
=
intrusive_ptr
<
local_actor
>
;
using
local_actor_ptr
=
intrusive_ptr
<
local_actor
>
;
// <backward_compatibility version="0.9">
// <backward_compatibility version="0.9">
inline
void
local_actor
::
send_tuple
(
message_priority
prio
,
const
channel
&
whom
,
inline
void
local_actor
::
send_tuple
(
message_priority
mp
,
const
channel
&
whom
,
message
what
)
{
message
what
)
{
send_impl
(
prio
,
whom
,
std
::
move
(
what
));
send_impl
(
mp
,
actor_cast
<
abstract_channel
*>
(
whom
)
,
std
::
move
(
what
));
}
}
inline
void
local_actor
::
send_tuple
(
const
channel
&
whom
,
message
what
)
{
inline
void
local_actor
::
send_tuple
(
const
channel
&
whom
,
message
what
)
{
send_impl
(
message_priority
::
normal
,
whom
,
std
::
move
(
what
));
send_impl
(
message_priority
::
normal
,
actor_cast
<
abstract_channel
*>
(
whom
),
std
::
move
(
what
));
}
}
inline
void
local_actor
::
delayed_send_tuple
(
message_priority
prio
,
inline
void
local_actor
::
delayed_send_tuple
(
message_priority
mp
,
const
channel
&
whom
,
const
channel
&
whom
,
const
duration
&
rtime
,
const
duration
&
rtime
,
message
data
)
{
message
data
)
{
delayed_send_impl
(
prio
,
whom
,
rtime
,
std
::
move
(
data
));
delayed_send_impl
(
mp
,
actor_cast
<
abstract_channel
*>
(
whom
),
rtime
,
std
::
move
(
data
));
}
}
inline
void
local_actor
::
delayed_send_tuple
(
const
channel
&
whom
,
inline
void
local_actor
::
delayed_send_tuple
(
const
channel
&
whom
,
const
duration
&
rtime
,
const
duration
&
rtime
,
message
data
)
{
message
data
)
{
delayed_send_impl
(
message_priority
::
normal
,
whom
,
rtime
,
std
::
move
(
data
));
delayed_send_impl
(
message_priority
::
normal
,
actor_cast
<
abstract_channel
*>
(
whom
),
rtime
,
std
::
move
(
data
));
}
}
// </backward_compatibility>
// </backward_compatibility>
...
...
libcaf_core/src/local_actor.cpp
View file @
51067802
...
@@ -124,7 +124,7 @@ void local_actor::forward_message(const actor& dest, message_priority prio) {
...
@@ -124,7 +124,7 @@ void local_actor::forward_message(const actor& dest, message_priority prio) {
}
}
void
local_actor
::
send_impl
(
message_priority
prio
,
abstract_channel
*
dest
,
void
local_actor
::
send_impl
(
message_priority
prio
,
abstract_channel
*
dest
,
message
&&
what
)
{
message
what
)
{
if
(
!
dest
)
{
if
(
!
dest
)
{
return
;
return
;
}
}
...
@@ -191,8 +191,8 @@ message_id local_actor::timed_sync_send_impl(message_priority mp,
...
@@ -191,8 +191,8 @@ message_id local_actor::timed_sync_send_impl(message_priority mp,
}
}
message_id
local_actor
::
sync_send_impl
(
message_priority
mp
,
message_id
local_actor
::
sync_send_impl
(
message_priority
mp
,
const
actor
&
dest
,
const
actor
&
dest
,
message
&&
what
)
{
message
&&
what
)
{
if
(
!
dest
)
{
if
(
!
dest
)
{
throw
std
::
invalid_argument
(
"cannot sync_send to invalid_actor"
);
throw
std
::
invalid_argument
(
"cannot sync_send to invalid_actor"
);
}
}
...
...
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