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
07b27254
Commit
07b27254
authored
Jan 07, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
documentation
parent
9366bd80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
cppa/actor_companion_mixin.hpp
cppa/actor_companion_mixin.hpp
+19
-0
No files found.
cppa/actor_companion_mixin.hpp
View file @
07b27254
...
...
@@ -47,6 +47,10 @@
namespace
cppa
{
/**
* @brief Adds co-existing objects (companions) to a class,
* which serve as gateways, thereby enabling libcppa's message passing.
*/
template
<
typename
Base
>
class
actor_companion_mixin
:
public
Base
{
...
...
@@ -65,20 +69,35 @@ class actor_companion_mixin : public Base {
m_self
->
disconnect
();
}
/**
* @brief Returns a smart pointer to the companion object.
*/
inline
actor_ptr
as_actor
()
const
{
return
m_self
;
}
protected:
/**
* @brief This callback is invoked by the companion object whenever a
* new messages arrives.
* @warning Implementation has to be thread-safe.
*/
virtual
void
new_message
(
message_pointer
ptr
)
=
0
;
/**
* @brief Defines the message handler.
* @note While the message handler is invoked, @p self will point
* to the companion object to enable send() and reply().
*/
template
<
typename
...
Args
>
void
set_message_handler
(
Args
&&
...
matchExpressions
)
{
m_message_handler
=
match_expr_concat
(
std
::
forward
<
Args
>
(
matchExpressions
)...);
}
/**
* @brief Invokes the message handler with @p msg.
* @note While the message handler is invoked, @p self will point
* to the companion object to enable send() and reply().
*/
void
handle_message
(
const
message_pointer
&
msg
)
{
if
(
!
msg
)
return
;
scoped_self_setter
sss
(
m_self
.
get
());
...
...
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