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
dfcbb117
Commit
dfcbb117
authored
Sep 08, 2016
by
Marian Triebe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mixins to use derived type
parent
00d77d3b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
13 deletions
+26
-13
libcaf_core/caf/mixin/behavior_changer.hpp
libcaf_core/caf/mixin/behavior_changer.hpp
+12
-7
libcaf_core/caf/mixin/sender.hpp
libcaf_core/caf/mixin/sender.hpp
+3
-3
libcaf_core/caf/mixin/subscriber.hpp
libcaf_core/caf/mixin/subscriber.hpp
+7
-3
libcaf_core/caf/typed_actor_view.hpp
libcaf_core/caf/typed_actor_view.hpp
+4
-0
No files found.
libcaf_core/caf/mixin/behavior_changer.hpp
View file @
dfcbb117
...
@@ -38,14 +38,14 @@ namespace mixin {
...
@@ -38,14 +38,14 @@ namespace mixin {
/// A `behavior_changer` is an actor that supports
/// A `behavior_changer` is an actor that supports
/// `self->become(...)` and `self->unbecome()`.
/// `self->become(...)` and `self->unbecome()`.
template
<
class
Base
,
class
Derived
>
template
<
class
Base
,
class
Subtype
>
class
behavior_changer
:
public
Base
{
class
behavior_changer
:
public
Base
{
public:
public:
// -- member types -----------------------------------------------------------
// -- member types -----------------------------------------------------------
using
extended_base
=
behavior_changer
;
using
extended_base
=
behavior_changer
;
using
behavior_type
=
typename
behavior_type_of
<
Derived
>::
type
;
using
behavior_type
=
typename
behavior_type_of
<
Subtype
>::
type
;
// -- constructors, destructors, and assignment operators --------------------
// -- constructors, destructors, and assignment operators --------------------
...
@@ -57,11 +57,11 @@ public:
...
@@ -57,11 +57,11 @@ public:
// -- behavior management ----------------------------------------------------
// -- behavior management ----------------------------------------------------
void
become
(
behavior_type
bhvr
)
{
void
become
(
behavior_type
bhvr
)
{
this
->
do_become
(
std
::
move
(
bhvr
.
unbox
()),
true
);
dptr
()
->
do_become
(
std
::
move
(
bhvr
.
unbox
()),
true
);
}
}
void
become
(
const
keep_behavior_t
&
,
behavior_type
bhvr
)
{
void
become
(
const
keep_behavior_t
&
,
behavior_type
bhvr
)
{
this
->
do_become
(
std
::
move
(
bhvr
.
unbox
()),
false
);
dptr
()
->
do_become
(
std
::
move
(
bhvr
.
unbox
()),
false
);
}
}
template
<
class
T0
,
class
T1
,
class
...
Ts
>
template
<
class
T0
,
class
T1
,
class
...
Ts
>
...
@@ -72,7 +72,7 @@ public:
...
@@ -72,7 +72,7 @@ public:
behavior_type
bhvr
{
std
::
forward
<
T0
>
(
x0
),
behavior_type
bhvr
{
std
::
forward
<
T0
>
(
x0
),
std
::
forward
<
T1
>
(
x1
),
std
::
forward
<
T1
>
(
x1
),
std
::
forward
<
Ts
>
(
xs
)...};
std
::
forward
<
Ts
>
(
xs
)...};
this
->
do_become
(
std
::
move
(
bhvr
.
unbox
()),
true
);
dptr
()
->
do_become
(
std
::
move
(
bhvr
.
unbox
()),
true
);
}
}
template
<
class
T0
,
class
T1
,
class
...
Ts
>
template
<
class
T0
,
class
T1
,
class
...
Ts
>
...
@@ -80,11 +80,16 @@ public:
...
@@ -80,11 +80,16 @@ public:
behavior_type
bhvr
{
std
::
forward
<
T0
>
(
x0
),
behavior_type
bhvr
{
std
::
forward
<
T0
>
(
x0
),
std
::
forward
<
T1
>
(
x1
),
std
::
forward
<
T1
>
(
x1
),
std
::
forward
<
Ts
>
(
xs
)...};
std
::
forward
<
Ts
>
(
xs
)...};
this
->
do_become
(
std
::
move
(
bhvr
.
unbox
()),
false
);
dptr
()
->
do_become
(
std
::
move
(
bhvr
.
unbox
()),
false
);
}
}
void
unbecome
()
{
void
unbecome
()
{
this
->
bhvr_stack_
.
pop_back
();
dptr
()
->
bhvr_stack_
.
pop_back
();
}
private:
Subtype
*
dptr
()
{
return
static_cast
<
Subtype
*>
(
this
);
}
}
};
};
...
...
libcaf_core/caf/mixin/sender.hpp
View file @
dfcbb117
...
@@ -77,8 +77,8 @@ public:
...
@@ -77,8 +77,8 @@ public:
typename
res_t
::
type
typename
res_t
::
type
>::
valid
,
>::
valid
,
"this actor does not accept the response message"
);
"this actor does not accept the response message"
);
dest
->
eq_impl
(
message_id
::
make
(
P
),
this
->
ctrl
(),
dest
->
eq_impl
(
message_id
::
make
(
P
),
dptr
()
->
ctrl
(),
this
->
context
(),
std
::
forward
<
Ts
>
(
xs
)...);
dptr
()
->
context
(),
std
::
forward
<
Ts
>
(
xs
)...);
}
}
template
<
message_priority
P
=
message_priority
::
normal
,
template
<
message_priority
P
=
message_priority
::
normal
,
...
@@ -96,7 +96,7 @@ public:
...
@@ -96,7 +96,7 @@ public:
>::
valid
,
>::
valid
,
"receiver does not accept given message"
);
"receiver does not accept given message"
);
dest
->
eq_impl
(
message_id
::
make
(
P
),
nullptr
,
dest
->
eq_impl
(
message_id
::
make
(
P
),
nullptr
,
this
->
context
(),
std
::
forward
<
Ts
>
(
xs
)...);
dptr
()
->
context
(),
std
::
forward
<
Ts
>
(
xs
)...);
}
}
template
<
message_priority
P
=
message_priority
::
normal
,
template
<
message_priority
P
=
message_priority
::
normal
,
...
...
libcaf_core/caf/mixin/subscriber.hpp
View file @
dfcbb117
...
@@ -57,7 +57,7 @@ public:
...
@@ -57,7 +57,7 @@ public:
// -- overridden functions of monitorable_actor ------------------------------
// -- overridden functions of monitorable_actor ------------------------------
bool
cleanup
(
error
&&
fail_state
,
execution_unit
*
ptr
)
override
{
bool
cleanup
(
error
&&
fail_state
,
execution_unit
*
ptr
)
override
{
auto
me
=
this
->
ctrl
();
auto
me
=
dptr
()
->
ctrl
();
for
(
auto
&
subscription
:
subscriptions_
)
for
(
auto
&
subscription
:
subscriptions_
)
subscription
->
unsubscribe
(
me
);
subscription
->
unsubscribe
(
me
);
subscriptions_
.
clear
();
subscriptions_
.
clear
();
...
@@ -72,7 +72,7 @@ public:
...
@@ -72,7 +72,7 @@ public:
CAF_LOG_TRACE
(
CAF_ARG
(
what
));
CAF_LOG_TRACE
(
CAF_ARG
(
what
));
if
(
what
==
invalid_group
)
if
(
what
==
invalid_group
)
return
;
return
;
if
(
what
->
subscribe
(
this
->
ctrl
()))
if
(
what
->
subscribe
(
dptr
()
->
ctrl
()))
subscriptions_
.
emplace
(
what
);
subscriptions_
.
emplace
(
what
);
}
}
...
@@ -80,7 +80,7 @@ public:
...
@@ -80,7 +80,7 @@ public:
void
leave
(
const
group
&
what
)
{
void
leave
(
const
group
&
what
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
what
));
CAF_LOG_TRACE
(
CAF_ARG
(
what
));
if
(
subscriptions_
.
erase
(
what
)
>
0
)
if
(
subscriptions_
.
erase
(
what
)
>
0
)
what
->
unsubscribe
(
this
->
ctrl
());
what
->
unsubscribe
(
dptr
()
->
ctrl
());
}
}
/// Returns all subscribed groups.
/// Returns all subscribed groups.
...
@@ -89,6 +89,10 @@ public:
...
@@ -89,6 +89,10 @@ public:
}
}
private:
private:
Subtype
*
dptr
()
{
return
static_cast
<
Subtype
*>
(
this
);
}
// -- data members -----------------------------------------------------------
// -- data members -----------------------------------------------------------
/// Stores all subscribed groups.
/// Stores all subscribed groups.
...
...
libcaf_core/caf/typed_actor_view.hpp
View file @
dfcbb117
...
@@ -71,6 +71,10 @@ public:
...
@@ -71,6 +71,10 @@ public:
* miscellaneous actor operations *
* miscellaneous actor operations *
****************************************************************************/
****************************************************************************/
execution_unit
*
context
()
const
{
return
self_
->
context
();
}
actor_system
&
system
()
const
{
actor_system
&
system
()
const
{
return
self_
->
system
();
return
self_
->
system
();
}
}
...
...
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