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
78f5ddfb
Commit
78f5ddfb
authored
Jul 30, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added send_tuple, sync_send_tuple and reply_tuple
parent
51e653ff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
20 deletions
+47
-20
cppa/cppa.hpp
cppa/cppa.hpp
+47
-20
No files found.
cppa/cppa.hpp
View file @
78f5ddfb
...
...
@@ -423,22 +423,14 @@ inline void send_tpl_impl(T* whom, Args&&... what) {
*/
/**
* @brief Sends a message to @p whom.
*
* <b>Usage example:</b>
* @code
* self << make_any_tuple(1, 2, 3);
* @endcode
* @brief Sends @p what as a message to @p whom.
* @param whom Receiver of the message.
* @param what Message as instance of {@link any_tuple}.
* @returns @p whom.
* @param what Message content as tuple.
*/
template
<
class
C
>
inline
typename
std
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>::
value
,
const
intrusive_ptr
<
C
>&
>::
type
operator
<<
(
const
intrusive_ptr
<
C
>&
whom
,
any_tuple
what
)
{
template
<
class
C
,
typename
...
Args
>
inline
typename
std
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>::
value
>::
type
send_tuple
(
const
intrusive_ptr
<
C
>&
whom
,
any_tuple
what
)
{
detail
::
send_impl
(
whom
.
get
(),
std
::
move
(
what
));
return
whom
;
}
/**
...
...
@@ -454,10 +446,43 @@ send(const intrusive_ptr<C>& whom, Args&&... what) {
detail
::
send_tpl_impl
(
whom
.
get
(),
std
::
forward
<
Args
>
(
what
)...);
}
/**
* @brief Sends a message to @p whom.
*
* <b>Usage example:</b>
* @code
* self << make_any_tuple(1, 2, 3);
* @endcode
* @param whom Receiver of the message.
* @param what Message as instance of {@link any_tuple}.
* @returns @p whom.
*/
template
<
class
C
>
inline
typename
std
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>::
value
,
const
intrusive_ptr
<
C
>&
>::
type
operator
<<
(
const
intrusive_ptr
<
C
>&
whom
,
any_tuple
what
)
{
send_tuple
(
whom
,
std
::
move
(
what
));
return
whom
;
}
#ifndef CPPA_DOCUMENTATION
typedef
message_id_t
message_future
;
#endif // CPPA_DOCUMENTATION
/**
* @brief Sends @p what as a synchronous message to @p whom.
* @param whom Receiver of the message.
* @param what Message content as tuple.
* @returns A handle identifying a future to the response of @p whom.
* @warning The returned handle is actor specific and the response to the sent
* message cannot be received by another actor.
* @throws std::invalid_argument if <tt>whom == nullptr</tt>
*/
inline
message_future
sync_send_tuple
(
const
actor_ptr
&
whom
,
any_tuple
what
)
{
if
(
whom
)
return
self
->
send_sync_message
(
whom
.
get
(),
std
::
move
(
what
));
else
throw
std
::
invalid_argument
(
"whom == nullptr"
);
}
/**
* @brief Sends <tt>{what...}</tt> as a synchronous message to @p whom.
* @param whom Receiver of the message.
...
...
@@ -471,12 +496,7 @@ typedef message_id_t message_future;
template
<
typename
...
Args
>
inline
message_future
sync_send
(
const
actor_ptr
&
whom
,
Args
&&
...
what
)
{
static_assert
(
sizeof
...(
Args
)
>
0
,
"no message to send"
);
if
(
whom
)
{
return
self
->
send_sync_message
(
whom
.
get
(),
make_any_tuple
(
std
::
forward
<
Args
>
(
what
)...));
}
else
throw
std
::
invalid_argument
(
"whom == nullptr"
);
return
sync_send_tuple
(
whom
,
make_any_tuple
(
std
::
forward
<
Args
>
(
what
)...));
}
/**
...
...
@@ -496,10 +516,17 @@ inline sync_recv_helper receive_response(message_future handle) {
}};
}
/**
* @brief Sends a message to the sender of the last received message.
* @param what Message content as a tuple.
*/
inline
void
reply_tuple
(
any_tuple
what
)
{
self
->
reply_message
(
std
::
move
(
what
));
}
/**
* @brief Sends a message to the sender of the last received message.
* @param what Message elements.
* @note Equal to <tt>send(self->last_received(), what...)</tt>.
*/
template
<
typename
...
Args
>
inline
void
reply
(
Args
&&
...
what
)
{
...
...
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