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
2c696667
Unverified
Commit
2c696667
authored
Feb 27, 2021
by
Noir
Committed by
GitHub
Feb 27, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1224
Fix creating typed_actor from typed_actor_pointer
parents
c1cded92
44a35778
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
2 deletions
+40
-2
CHANGELOG.md
CHANGELOG.md
+6
-0
libcaf_core/caf/typed_actor.hpp
libcaf_core/caf/typed_actor.hpp
+1
-1
libcaf_core/caf/typed_actor_pointer.hpp
libcaf_core/caf/typed_actor_pointer.hpp
+5
-0
libcaf_core/caf/typed_actor_view.hpp
libcaf_core/caf/typed_actor_view.hpp
+0
-1
libcaf_core/test/typed_spawn.cpp
libcaf_core/test/typed_spawn.cpp
+28
-0
No files found.
CHANGELOG.md
View file @
2c696667
...
@@ -5,6 +5,12 @@ is based on [Keep a Changelog](https://keepachangelog.com).
...
@@ -5,6 +5,12 @@ is based on [Keep a Changelog](https://keepachangelog.com).
## [Unreleased]
## [Unreleased]
### Fixed
-
The handle type
`typed_actor`
now can construct from a
`typed_actor_pointer`
.
This resolves a compiler error when trying to initialize a handle for
`my_handle`
from a self pointer of type
`my_handle::pointer_view`
.
## [0.18.0] - 2021-01-25
## [0.18.0] - 2021-01-25
### Added
### Added
...
...
libcaf_core/caf/typed_actor.hpp
View file @
2c696667
...
@@ -137,7 +137,7 @@ public:
...
@@ -137,7 +137,7 @@ public:
// Enable `handle_type{self}` for typed actor views.
// Enable `handle_type{self}` for typed actor views.
template
<
class
T
,
class
=
std
::
enable_if_t
<
template
<
class
T
,
class
=
std
::
enable_if_t
<
std
::
is_base_of
<
typed_actor_view_base
,
T
>
::
value
>>
std
::
is_base_of
<
typed_actor_view_base
,
T
>
::
value
>>
explicit
typed_actor
(
T
ptr
)
:
ptr_
(
ptr
.
internal_ptr
())
{
explicit
typed_actor
(
T
ptr
)
:
ptr_
(
ptr
.
ctrl
())
{
static_assert
(
static_assert
(
detail
::
tl_subset_of
<
signatures
,
typename
T
::
signatures
>::
value
,
detail
::
tl_subset_of
<
signatures
,
typename
T
::
signatures
>::
value
,
"Cannot assign T to incompatible handle type"
);
"Cannot assign T to incompatible handle type"
);
...
...
libcaf_core/caf/typed_actor_pointer.hpp
View file @
2c696667
...
@@ -85,6 +85,11 @@ public:
...
@@ -85,6 +85,11 @@ public:
return
view_
.
ctrl
();
return
view_
.
ctrl
();
}
}
/// @private
actor_control_block
*
ctrl
()
const
noexcept
{
return
view_
.
ctrl
();
}
/// @private
/// @private
scheduled_actor
*
internal_ptr
()
const
noexcept
{
scheduled_actor
*
internal_ptr
()
const
noexcept
{
return
view_
.
internal_ptr
();
return
view_
.
internal_ptr
();
...
...
libcaf_core/caf/typed_actor_view.hpp
View file @
2c696667
...
@@ -268,7 +268,6 @@ public:
...
@@ -268,7 +268,6 @@ public:
actor_control_block
*
ctrl
()
const
noexcept
{
actor_control_block
*
ctrl
()
const
noexcept
{
CAF_ASSERT
(
self_
!=
nullptr
);
CAF_ASSERT
(
self_
!=
nullptr
);
return
actor_control_block
::
from
(
self_
);
return
actor_control_block
::
from
(
self_
);
;
}
}
/// @private
/// @private
...
...
libcaf_core/test/typed_spawn.cpp
View file @
2c696667
...
@@ -372,6 +372,34 @@ CAF_TEST(check_signature) {
...
@@ -372,6 +372,34 @@ CAF_TEST(check_signature) {
run
();
run
();
}
}
SCENARIO
(
"state classes may use typed pointers"
)
{
GIVEN
(
"a state class for a statically typed actor type"
)
{
using
foo_type
=
typed_actor
<
result
<
int32_t
>
(
get_atom
)
>
;
struct
foo_state
{
foo_state
(
foo_type
::
pointer_view
selfptr
)
:
self
(
selfptr
)
{
foo_type
hdl
{
self
};
CHECK_EQ
(
selfptr
,
actor_cast
<
abstract_actor
*>
(
hdl
));
foo_type
hdl2
{
selfptr
};
CHECK_EQ
(
hdl
,
hdl2
);
}
foo_type
::
behavior_type
make_behavior
()
{
return
{
[](
get_atom
)
{
return
int32_t
{
42
};
},
};
}
foo_type
::
pointer_view
self
;
};
using
foo_impl
=
stateful_actor
<
foo_state
,
foo_type
::
impl
>
;
WHEN
(
"spawning a stateful actor using the state class"
)
{
auto
foo
=
sys
.
spawn
<
foo_impl
>
();
THEN
(
"the actor calls make_behavior of the state class"
)
{
inject
((
get_atom
),
from
(
self
).
to
(
foo
).
with
(
get_atom_v
));
expect
((
int32_t
),
from
(
foo
).
to
(
self
).
with
(
42
));
}
}
}
}
CAF_TEST_FIXTURE_SCOPE_END
()
CAF_TEST_FIXTURE_SCOPE_END
()
#endif // CAF_WINDOWS
#endif // CAF_WINDOWS
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