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
99212ecc
Unverified
Commit
99212ecc
authored
Mar 19, 2020
by
Dominik Charousset
Committed by
GitHub
Mar 19, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1072
Fix several issues with typed actor views
parents
13d75ffe
90ce18a1
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
182 additions
and
83 deletions
+182
-83
CHANGELOG.md
CHANGELOG.md
+5
-0
CMakeLists.txt
CMakeLists.txt
+4
-0
libcaf_core/caf/actor_profiler.hpp
libcaf_core/caf/actor_profiler.hpp
+1
-1
libcaf_core/caf/attach_continuous_stream_source.hpp
libcaf_core/caf/attach_continuous_stream_source.hpp
+1
-4
libcaf_core/caf/attach_stream_source.hpp
libcaf_core/caf/attach_stream_source.hpp
+4
-7
libcaf_core/caf/local_actor.hpp
libcaf_core/caf/local_actor.hpp
+8
-7
libcaf_core/caf/scheduled_actor.hpp
libcaf_core/caf/scheduled_actor.hpp
+36
-47
libcaf_core/caf/typed_actor.hpp
libcaf_core/caf/typed_actor.hpp
+10
-0
libcaf_core/caf/typed_actor_pointer.hpp
libcaf_core/caf/typed_actor_pointer.hpp
+5
-1
libcaf_core/caf/typed_actor_view.hpp
libcaf_core/caf/typed_actor_view.hpp
+108
-16
No files found.
CHANGELOG.md
View file @
99212ecc
...
@@ -89,6 +89,11 @@ is based on [Keep a Changelog](https://keepachangelog.com).
...
@@ -89,6 +89,11 @@ is based on [Keep a Changelog](https://keepachangelog.com).
could monitor typed actors but not demonitoring it again. This member function
could monitor typed actors but not demonitoring it again. This member function
is now a template that accepts any actor handle in the same way
`monitor`
is now a template that accepts any actor handle in the same way
`monitor`
already did.
already did.
-
The
`typed_actor_view`
decorator lacked several member functions such as
`link_to`
,
`send_exit`
, etc. These are now available.
-
Constructing a
`typed_actor`
handle from a pointer view failed du to a missing
constructor overload. This (explicit) overload now exists and the conversion
should work as expected.
## [0.17.5] - Unreleased
## [0.17.5] - Unreleased
...
...
CMakeLists.txt
View file @
99212ecc
...
@@ -322,6 +322,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
...
@@ -322,6 +322,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
add_compile_options
(
"-ftemplate-depth=512"
add_compile_options
(
"-ftemplate-depth=512"
"-ftemplate-backtrace-limit=0"
)
"-ftemplate-backtrace-limit=0"
)
endif
()
endif
()
# enable useful warnings by default
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
add_compile_options
(
-Wdocumentation
)
endif
()
# explicitly disable obnoxious GCC warnings
# explicitly disable obnoxious GCC warnings
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
build_string
(
"EXTRA_FLAGS"
"-Wno-missing-field-initializers"
)
build_string
(
"EXTRA_FLAGS"
"-Wno-missing-field-initializers"
)
...
...
libcaf_core/caf/actor_profiler.hpp
View file @
99212ecc
...
@@ -44,7 +44,7 @@ public:
...
@@ -44,7 +44,7 @@ public:
=
0
;
=
0
;
/// Called before the actor system calls the destructor for `self`.
/// Called before the actor system calls the destructor for `self`.
/// @param
ptr
Points to an actor that is about to get destroyed.
/// @param
self
Points to an actor that is about to get destroyed.
/// @thread-safe
/// @thread-safe
virtual
void
remove_actor
(
const
local_actor
&
self
)
=
0
;
virtual
void
remove_actor
(
const
local_actor
&
self
)
=
0
;
...
...
libcaf_core/caf/attach_continuous_stream_source.hpp
View file @
99212ecc
...
@@ -33,10 +33,7 @@ namespace caf {
...
@@ -33,10 +33,7 @@ namespace caf {
/// implementation with `Driver`. The returned manager is not connected to any
/// implementation with `Driver`. The returned manager is not connected to any
/// slot and thus not stored by the actor automatically.
/// slot and thus not stored by the actor automatically.
/// @param self Points to the hosting actor.
/// @param self Points to the hosting actor.
/// @param init Function object for initializing the state of the source.
/// @param xs Parameter pack for constructing the driver.
/// @param pull Generator function object for producing downstream messages.
/// @param done Predicate returning `true` when generator is done.
/// @param fin Cleanup handler.
/// @returns The new `stream_manager`.
/// @returns The new `stream_manager`.
template
<
class
Driver
,
class
...
Ts
>
template
<
class
Driver
,
class
...
Ts
>
typename
Driver
::
source_ptr_type
typename
Driver
::
source_ptr_type
...
...
libcaf_core/caf/attach_stream_source.hpp
View file @
99212ecc
...
@@ -40,10 +40,7 @@ namespace caf {
...
@@ -40,10 +40,7 @@ namespace caf {
/// manager with `Driver`.
/// manager with `Driver`.
/// @param self Points to the hosting actor.
/// @param self Points to the hosting actor.
/// @param xs User-defined arguments for the stream handshake.
/// @param xs User-defined arguments for the stream handshake.
/// @param init Function object for initializing the state of the source.
/// @param ctor_args Parameter pack for constructing the driver.
/// @param pull Function object for generating downstream messages.
/// @param done Predicate returning `true` when generator is done.
/// @param fin Optional cleanup handler.
/// @returns The allocated `stream_manager` and the output slot.
/// @returns The allocated `stream_manager` and the output slot.
template
<
class
Driver
,
class
...
Ts
,
class
...
CtorArgs
>
template
<
class
Driver
,
class
...
Ts
,
class
...
CtorArgs
>
make_source_result_t
<
typename
Driver
::
downstream_manager_type
,
Ts
...
>
make_source_result_t
<
typename
Driver
::
downstream_manager_type
,
Ts
...
>
...
@@ -104,10 +101,10 @@ template <class Init, class Pull, class Done, class Finalize = unit_t,
...
@@ -104,10 +101,10 @@ template <class Init, class Pull, class Done, class Finalize = unit_t,
detail
::
enable_if_t
<!
is_actor_handle
<
Init
>::
value
&&
Trait
::
valid
,
detail
::
enable_if_t
<!
is_actor_handle
<
Init
>::
value
&&
Trait
::
valid
,
make_source_result_t
<
DownstreamManager
>>
make_source_result_t
<
DownstreamManager
>>
attach_stream_source
(
scheduled_actor
*
self
,
Init
init
,
Pull
pull
,
Done
done
,
attach_stream_source
(
scheduled_actor
*
self
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
alize
=
{},
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
return
attach_stream_source
(
self
,
std
::
make_tuple
(),
init
,
pull
,
done
,
return
attach_stream_source
(
self
,
std
::
make_tuple
(),
init
,
pull
,
done
,
fin
,
finalize
,
token
);
token
);
}
}
/// Attaches a new stream source to `self` by creating a default stream source
/// Attaches a new stream source to `self` by creating a default stream source
...
...
libcaf_core/caf/local_actor.hpp
View file @
99212ecc
...
@@ -167,16 +167,17 @@ public:
...
@@ -167,16 +167,17 @@ public:
// -- sending asynchronous messages ------------------------------------------
// -- sending asynchronous messages ------------------------------------------
/// Sends an exit message to `
dest
`.
/// Sends an exit message to `
whom
`.
void
send_exit
(
const
actor_addr
&
whom
,
error
reason
);
void
send_exit
(
const
actor_addr
&
whom
,
error
reason
);
void
send_exit
(
const
strong_actor_ptr
&
dest
,
error
reason
);
/// Sends an exit message to `whom`.
void
send_exit
(
const
strong_actor_ptr
&
whom
,
error
reason
);
/// Sends an exit message to `
dest
`.
/// Sends an exit message to `
whom
`.
template
<
class
ActorHandle
>
template
<
class
ActorHandle
>
void
send_exit
(
const
ActorHandle
&
dest
,
error
reason
)
{
void
send_exit
(
const
ActorHandle
&
whom
,
error
reason
)
{
if
(
dest
)
if
(
whom
)
dest
->
eq_impl
(
make_message_id
(),
ctrl
(),
context
(),
whom
->
eq_impl
(
make_message_id
(),
ctrl
(),
context
(),
exit_msg
{
address
(),
std
::
move
(
reason
)});
exit_msg
{
address
(),
std
::
move
(
reason
)});
}
}
...
@@ -294,7 +295,7 @@ public:
...
@@ -294,7 +295,7 @@ public:
/// Adds a unidirectional `monitor` to `whom`.
/// Adds a unidirectional `monitor` to `whom`.
/// @note Each call to `monitor` creates a new, independent monitor.
/// @note Each call to `monitor` creates a new, independent monitor.
template
<
message_priority
P
=
message_priority
::
normal
,
class
Handle
=
actor
>
template
<
message_priority
P
=
message_priority
::
normal
,
class
Handle
>
void
monitor
(
const
Handle
&
whom
)
{
void
monitor
(
const
Handle
&
whom
)
{
monitor
(
actor_cast
<
abstract_actor
*>
(
whom
),
P
);
monitor
(
actor_cast
<
abstract_actor
*>
(
whom
),
P
);
}
}
...
...
libcaf_core/caf/scheduled_actor.hpp
View file @
99212ecc
...
@@ -300,23 +300,16 @@ public:
...
@@ -300,23 +300,16 @@ public:
// -- state modifiers --------------------------------------------------------
// -- state modifiers --------------------------------------------------------
/// Finishes execution of this actor after any currently running
/// Finishes execution of this actor after any currently running message
/// message handler is done.
/// handler is done. This member function clears the behavior stack of the
/// This member function clears the behavior stack of the running actor
/// running actor and invokes `on_exit()`. The actors does not finish
/// and invokes `on_exit()`. The actors does not finish execution
/// execution if the implementation of `on_exit()` sets a new behavior. When
/// if the implementation of `on_exit()` sets a new behavior.
/// setting a new behavior in `on_exit()`, one has to make sure to not produce
/// When setting a new behavior in `on_exit()`, one has to make sure
/// an infinite recursion.
/// to not produce an infinite recursion.
///
///
/// If `on_exit()` did not set a new behavior, the actor sends an
/// If `on_exit()` did not set a new behavior, the actor sends an exit message
/// exit message to all of its linked actors, sets its state to exited
/// to all of its linked actors, sets its state to exited and finishes
/// and finishes execution.
/// execution.
///
/// In case this actor uses the blocking API, this member function unwinds
/// the stack by throwing an `actor_exited` exception.
/// @warning This member function throws immediately in thread-based actors
/// that do not use the behavior stack, i.e., actors that use
/// blocking API calls such as {@link receive()}.
void
quit
(
error
x
=
error
{});
void
quit
(
error
x
=
error
{});
// -- properties -------------------------------------------------------------
// -- properties -------------------------------------------------------------
...
@@ -436,10 +429,10 @@ public:
...
@@ -436,10 +429,10 @@ public:
// -- stream management ------------------------------------------------------
// -- stream management ------------------------------------------------------
/// @deprecated Please use `attach_stream_source` instead.
template
<
class
Driver
,
class
...
Ts
,
class
Init
,
class
Pull
,
class
Done
,
template
<
class
Driver
,
class
...
Ts
,
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
>
class
Finalize
=
unit_t
>
make_source_result_t
<
typename
Driver
::
downstream_manager_type
,
Ts
...
>
[[
deprecated
(
"use attach_stream_source instead"
)]]
make_source_result_t
<
typename
Driver
::
downstream_manager_type
,
Ts
...
>
make_source
(
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Pull
pull
,
Done
done
,
make_source
(
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{})
{
Finalize
fin
=
{})
{
using
detail
::
make_stream_source
;
using
detail
::
make_stream_source
;
...
@@ -449,12 +442,12 @@ public:
...
@@ -449,12 +442,12 @@ public:
return
{
slot
,
std
::
move
(
mgr
)};
return
{
slot
,
std
::
move
(
mgr
)};
}
}
/// @deprecated Please use `attach_stream_source` instead.
template
<
class
...
Ts
,
class
Init
,
class
Pull
,
class
Done
,
template
<
class
...
Ts
,
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
class
Finalize
=
unit_t
,
class
DownstreamManager
=
broadcast_downstream_manager
<
class
DownstreamManager
=
broadcast_downstream_manager
<
typename
stream_source_trait_t
<
Pull
>
::
output
>>
typename
stream_source_trait_t
<
Pull
>
::
output
>>
make_source_result_t
<
DownstreamManager
,
Ts
...
>
[[
deprecated
(
"use attach_stream_source instead"
)]]
make_source_result_t
<
DownstreamManager
,
Ts
...
>
make_source
(
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Pull
pull
,
Done
done
,
make_source
(
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
=
{})
{
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
=
{})
{
using
driver
=
detail
::
stream_source_driver_impl
<
DownstreamManager
,
Pull
,
using
driver
=
detail
::
stream_source_driver_impl
<
DownstreamManager
,
Pull
,
...
@@ -463,24 +456,24 @@ public:
...
@@ -463,24 +456,24 @@ public:
std
::
move
(
done
),
std
::
move
(
fin
));
std
::
move
(
done
),
std
::
move
(
fin
));
}
}
/// @deprecated Please use `attach_stream_source` instead.
template
<
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
template
<
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
class
DownstreamManager
=
default_downstream_manager_t
<
Pull
>,
class
DownstreamManager
=
default_downstream_manager_t
<
Pull
>,
class
Trait
=
stream_source_trait_t
<
Pull
>>
class
Trait
=
stream_source_trait_t
<
Pull
>>
detail
::
enable_if_t
<!
is_actor_handle
<
Init
>::
value
&&
Trait
::
valid
,
[[
deprecated
(
"use attach_stream_source instead"
)]]
detail
::
enable_if_t
<
make_source_result_t
<
DownstreamManager
>>
!
is_actor_handle
<
Init
>::
value
&&
Trait
::
valid
,
make_source_result_t
<
DownstreamManager
>>
make_source
(
Init
init
,
Pull
pull
,
Done
done
,
Finalize
finalize
=
{},
make_source
(
Init
init
,
Pull
pull
,
Done
done
,
Finalize
finalize
=
{},
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
return
make_source
(
std
::
make_tuple
(),
init
,
pull
,
done
,
finalize
,
token
);
return
make_source
(
std
::
make_tuple
(),
init
,
pull
,
done
,
finalize
,
token
);
}
}
/// @deprecated Please use `attach_stream_source` instead.
template
<
class
ActorHandle
,
class
...
Ts
,
class
Init
,
class
Pull
,
class
Done
,
template
<
class
ActorHandle
,
class
...
Ts
,
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
class
Finalize
=
unit_t
,
class
DownstreamManager
=
default_downstream_manager_t
<
Pull
>,
class
DownstreamManager
=
default_downstream_manager_t
<
Pull
>,
class
Trait
=
stream_source_trait_t
<
Pull
>>
class
Trait
=
stream_source_trait_t
<
Pull
>>
detail
::
enable_if_t
<
is_actor_handle
<
ActorHandle
>::
value
,
[[
deprecated
(
"use attach_stream_source instead"
)]]
detail
::
enable_if_t
<
make_source_result_t
<
DownstreamManager
>>
is_actor_handle
<
ActorHandle
>::
value
,
make_source_result_t
<
DownstreamManager
>>
make_source
(
const
ActorHandle
&
dest
,
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
make_source
(
const
ActorHandle
&
dest
,
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{},
Pull
pull
,
Done
done
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
=
{})
{
policy
::
arg
<
DownstreamManager
>
=
{})
{
...
@@ -493,23 +486,22 @@ public:
...
@@ -493,23 +486,22 @@ public:
return
{
slot
,
std
::
move
(
mgr
)};
return
{
slot
,
std
::
move
(
mgr
)};
}
}
/// @deprecated Please use `attach_stream_source` instead.
template
<
class
ActorHandle
,
class
Init
,
class
Pull
,
class
Done
,
template
<
class
ActorHandle
,
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
class
Finalize
=
unit_t
,
class
DownstreamManager
=
default_downstream_manager_t
<
Pull
>,
class
DownstreamManager
=
default_downstream_manager_t
<
Pull
>,
class
Trait
=
stream_source_trait_t
<
Pull
>>
class
Trait
=
stream_source_trait_t
<
Pull
>>
detail
::
enable_if_t
<
is_actor_handle
<
ActorHandle
>::
value
&&
Trait
::
valid
,
[[
deprecated
(
"use attach_stream_source instead"
)]]
detail
::
enable_if_t
<
make_source_result_t
<
DownstreamManager
>>
is_actor_handle
<
ActorHandle
>::
value
&&
Trait
::
valid
,
make_source_result_t
<
DownstreamManager
>>
make_source
(
const
ActorHandle
&
dest
,
Init
init
,
Pull
pull
,
Done
done
,
make_source
(
const
ActorHandle
&
dest
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
return
make_source
(
dest
,
std
::
make_tuple
(),
std
::
move
(
init
),
return
make_source
(
dest
,
std
::
make_tuple
(),
std
::
move
(
init
),
std
::
move
(
pull
),
std
::
move
(
done
),
std
::
move
(
fin
),
token
);
std
::
move
(
pull
),
std
::
move
(
done
),
std
::
move
(
fin
),
token
);
}
}
/// @deprecated Please use `attach_continuous_stream_source` instead.
template
<
class
Driver
,
class
Init
,
class
Pull
,
class
Done
,
template
<
class
Driver
,
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
>
class
Finalize
=
unit_t
>
typename
Driver
::
source_ptr_type
[[
deprecated
(
"use attach_continuous_stream_source instead"
)]]
auto
make_continuous_source
(
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{})
{
make_continuous_source
(
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{})
{
using
detail
::
make_stream_source
;
using
detail
::
make_stream_source
;
auto
mgr
=
make_stream_source
<
Driver
>
(
auto
mgr
=
make_stream_source
<
Driver
>
(
...
@@ -518,11 +510,10 @@ public:
...
@@ -518,11 +510,10 @@ public:
return
mgr
;
return
mgr
;
}
}
/// @deprecated Please use `attach_continuous_stream_source` instead.
template
<
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
template
<
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
class
DownstreamManager
=
broadcast_downstream_manager
<
class
DownstreamManager
=
broadcast_downstream_manager
<
typename
stream_source_trait_t
<
Pull
>
::
output
>>
typename
stream_source_trait_t
<
Pull
>
::
output
>>
stream_source_ptr
<
DownstreamManager
>
[[
deprecated
(
"use attach_continuous_stream_source instead"
)]]
auto
make_continuous_source
(
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{},
make_continuous_source
(
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
=
{})
{
policy
::
arg
<
DownstreamManager
>
=
{})
{
using
driver
=
detail
::
stream_source_driver_impl
<
DownstreamManager
,
Pull
,
using
driver
=
detail
::
stream_source_driver_impl
<
DownstreamManager
,
Pull
,
...
@@ -531,28 +522,27 @@ public:
...
@@ -531,28 +522,27 @@ public:
std
::
move
(
done
),
std
::
move
(
fin
));
std
::
move
(
done
),
std
::
move
(
fin
));
}
}
/// @deprecated Please use `attach_stream_sink` instead.
template
<
class
Driver
,
class
...
Ts
>
template
<
class
Driver
,
class
...
Ts
>
make_sink_result
<
typename
Driver
::
input_type
>
[[
deprecated
(
"use attach_stream_sink instead"
)]]
make_sink_result
<
typename
Driver
::
input_type
>
make_sink
(
const
stream
<
typename
Driver
::
input_type
>&
src
,
Ts
&&
...
xs
)
{
make_sink
(
const
stream
<
typename
Driver
::
input_type
>&
src
,
Ts
&&
...
xs
)
{
auto
mgr
=
detail
::
make_stream_sink
<
Driver
>
(
this
,
std
::
forward
<
Ts
>
(
xs
)...);
auto
mgr
=
detail
::
make_stream_sink
<
Driver
>
(
this
,
std
::
forward
<
Ts
>
(
xs
)...);
auto
slot
=
mgr
->
add_inbound_path
(
src
);
auto
slot
=
mgr
->
add_inbound_path
(
src
);
return
{
slot
,
std
::
move
(
mgr
)};
return
{
slot
,
std
::
move
(
mgr
)};
}
}
/// @deprecated Please use `attach_stream_sink` instead.
template
<
class
In
,
class
Init
,
class
Fun
,
class
Finalize
=
unit_t
,
template
<
class
In
,
class
Init
,
class
Fun
,
class
Finalize
=
unit_t
,
class
Trait
=
stream_sink_trait_t
<
Fun
>
>
class
Trait
=
stream_sink_trait_t
<
Fun
>
>
make_sink_result
<
In
>
[[
deprecated
(
"use attach_stream_sink instead"
)]]
make_sink_result
<
In
>
make_sink
(
const
stream
<
In
>&
in
,
Init
init
,
Fun
fun
,
Finalize
fin
=
{})
{
make_sink
(
const
stream
<
In
>&
in
,
Init
init
,
Fun
fun
,
Finalize
fin
=
{})
{
using
driver
=
detail
::
stream_sink_driver_impl
<
In
,
Fun
,
Finalize
>
;
using
driver
=
detail
::
stream_sink_driver_impl
<
In
,
Fun
,
Finalize
>
;
return
make_sink
<
driver
>
(
in
,
std
::
move
(
init
),
std
::
move
(
fun
),
return
make_sink
<
driver
>
(
in
,
std
::
move
(
init
),
std
::
move
(
fun
),
std
::
move
(
fin
));
std
::
move
(
fin
));
}
}
/// @deprecated Please use `attach_stream_stage` instead.
template
<
class
Driver
,
class
In
,
class
...
Ts
,
class
...
Us
>
template
<
class
Driver
,
class
In
,
class
...
Ts
,
class
...
Us
>
make_stage_result_t
<
In
,
typename
Driver
::
downstream_manager_type
,
Ts
...
>
[[
deprecated
(
"use attach_stream_stage instead"
)]]
make_stage_result_t
<
In
,
typename
Driver
::
downstream_manager_type
,
Ts
...
>
make_stage
(
const
stream
<
In
>&
src
,
std
::
tuple
<
Ts
...
>
xs
,
Us
&&
...
ys
)
{
make_stage
(
const
stream
<
In
>&
src
,
std
::
tuple
<
Ts
...
>
xs
,
Us
&&
...
ys
)
{
using
detail
::
make_stream_stage
;
using
detail
::
make_stream_stage
;
auto
mgr
=
make_stream_stage
<
Driver
>
(
this
,
std
::
forward
<
Us
>
(
ys
)...);
auto
mgr
=
make_stream_stage
<
Driver
>
(
this
,
std
::
forward
<
Us
>
(
ys
)...);
...
@@ -561,12 +551,12 @@ public:
...
@@ -561,12 +551,12 @@ public:
return
{
in
,
out
,
std
::
move
(
mgr
)};
return
{
in
,
out
,
std
::
move
(
mgr
)};
}
}
/// @deprecated Please use `attach_stream_stage` instead.
template
<
class
In
,
class
...
Ts
,
class
Init
,
class
Fun
,
template
<
class
In
,
class
...
Ts
,
class
Init
,
class
Fun
,
class
Finalize
=
unit_t
,
class
Finalize
=
unit_t
,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
Trait
=
stream_stage_trait_t
<
Fun
>>
class
Trait
=
stream_stage_trait_t
<
Fun
>>
make_stage_result_t
<
In
,
DownstreamManager
,
Ts
...
>
[[
deprecated
(
"use attach_stream_stage instead"
)]]
make_stage_result_t
<
In
,
DownstreamManager
,
Ts
...
>
make_stage
(
const
stream
<
In
>&
in
,
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Fun
fun
,
make_stage
(
const
stream
<
In
>&
in
,
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Fun
fun
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
CAF_IGNORE_UNUSED
(
token
);
CAF_IGNORE_UNUSED
(
token
);
...
@@ -591,30 +581,29 @@ public:
...
@@ -591,30 +581,29 @@ public:
std
::
move
(
fun
),
std
::
move
(
fin
));
std
::
move
(
fun
),
std
::
move
(
fin
));
}
}
/// @deprecated Please use `attach_stream_stage` instead.
template
<
class
In
,
class
Init
,
class
Fun
,
class
Finalize
=
unit_t
,
template
<
class
In
,
class
Init
,
class
Fun
,
class
Finalize
=
unit_t
,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
Trait
=
stream_stage_trait_t
<
Fun
>>
class
Trait
=
stream_stage_trait_t
<
Fun
>>
make_stage_result_t
<
In
,
DownstreamManager
>
[[
deprecated
(
"use attach_stream_stage instead"
)]]
make_stage_result_t
<
In
,
DownstreamManager
>
make_stage
(
const
stream
<
In
>&
in
,
Init
init
,
Fun
fun
,
Finalize
fin
=
{},
make_stage
(
const
stream
<
In
>&
in
,
Init
init
,
Fun
fun
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
return
make_stage
(
in
,
std
::
make_tuple
(),
std
::
move
(
init
),
std
::
move
(
fun
),
return
make_stage
(
in
,
std
::
make_tuple
(),
std
::
move
(
init
),
std
::
move
(
fun
),
std
::
move
(
fin
),
token
);
std
::
move
(
fin
),
token
);
}
}
/// @deprecated Please use `attach_continuous_stream_stage` instead.
template
<
class
Driver
,
class
...
Ts
>
template
<
class
Driver
,
class
...
Ts
>
typename
Driver
::
stage_ptr_type
make_continuous_stage
(
Ts
&&
...
xs
)
{
[[
deprecated
(
"use attach_continuous_stream_stage instead"
)]]
auto
make_continuous_stage
(
Ts
&&
...
xs
)
{
auto
ptr
=
detail
::
make_stream_stage
<
Driver
>
(
this
,
std
::
forward
<
Ts
>
(
xs
)...);
auto
ptr
=
detail
::
make_stream_stage
<
Driver
>
(
this
,
std
::
forward
<
Ts
>
(
xs
)...);
ptr
->
continuous
(
true
);
ptr
->
continuous
(
true
);
return
ptr
;
return
ptr
;
}
}
/// @deprecated Please use `attach_continuous_stream_stage` instead.
template
<
class
Init
,
class
Fun
,
class
Cleanup
,
template
<
class
Init
,
class
Fun
,
class
Cleanup
,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
Trait
=
stream_stage_trait_t
<
Fun
>>
class
Trait
=
stream_stage_trait_t
<
Fun
>>
stream_stage_ptr
<
typename
Trait
::
input
,
DownstreamManager
>
[[
deprecated
(
"use attach_continuous_stream_stage instead"
)]]
auto
make_continuous_stage
(
Init
init
,
Fun
fun
,
Cleanup
cleanup
,
make_continuous_stage
(
Init
init
,
Fun
fun
,
Cleanup
cleanup
,
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
CAF_IGNORE_UNUSED
(
token
);
CAF_IGNORE_UNUSED
(
token
);
...
...
libcaf_core/caf/typed_actor.hpp
View file @
99212ecc
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "caf/make_actor.hpp"
#include "caf/make_actor.hpp"
#include "caf/replies_to.hpp"
#include "caf/replies_to.hpp"
#include "caf/stateful_actor.hpp"
#include "caf/stateful_actor.hpp"
#include "caf/typed_actor_view_base.hpp"
#include "caf/typed_behavior.hpp"
#include "caf/typed_behavior.hpp"
#include "caf/typed_response_promise.hpp"
#include "caf/typed_response_promise.hpp"
...
@@ -148,6 +149,15 @@ public:
...
@@ -148,6 +149,15 @@ public:
CAF_ASSERT
(
ptr
!=
nullptr
);
CAF_ASSERT
(
ptr
!=
nullptr
);
}
}
// Enable `handle_type{self}` for typed actor views.
template
<
class
T
,
class
=
std
::
enable_if_t
<
std
::
is_base_of
<
typed_actor_view_base
,
T
>
::
value
>>
explicit
typed_actor
(
T
ptr
)
:
ptr_
(
ptr
.
internal_ptr
())
{
static_assert
(
detail
::
tl_subset_of
<
signatures
,
typename
T
::
signatures
>::
value
,
"Cannot assign T to incompatible handle type"
);
}
template
<
class
...
Ts
>
template
<
class
...
Ts
>
typed_actor
&
operator
=
(
const
typed_actor
<
Ts
...
>&
other
)
{
typed_actor
&
operator
=
(
const
typed_actor
<
Ts
...
>&
other
)
{
static_assert
(
static_assert
(
...
...
libcaf_core/caf/typed_actor_pointer.hpp
View file @
99212ecc
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
namespace
caf
{
namespace
caf
{
template
<
class
...
Sigs
>
template
<
class
...
Sigs
>
class
typed_actor_pointer
{
class
typed_actor_pointer
:
public
typed_actor_view_base
{
public:
public:
/// Stores the template parameter pack.
/// Stores the template parameter pack.
using
signatures
=
detail
::
type_list
<
Sigs
...
>
;
using
signatures
=
detail
::
type_list
<
Sigs
...
>
;
...
@@ -45,6 +45,10 @@ public:
...
@@ -45,6 +45,10 @@ public:
// nop
// nop
}
}
typed_actor_pointer
(
const
typed_actor_pointer
&
)
=
default
;
typed_actor_pointer
&
operator
=
(
const
typed_actor_pointer
&
)
=
default
;
typed_actor_view
<
Sigs
...
>*
operator
->
()
{
typed_actor_view
<
Sigs
...
>*
operator
->
()
{
return
&
view_
;
return
&
view_
;
}
}
...
...
libcaf_core/caf/typed_actor_view.hpp
View file @
99212ecc
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#pragma once
#pragma once
#include "caf/actor_traits.hpp"
#include "caf/actor_traits.hpp"
#include "caf/config.hpp"
#include "caf/mixin/requester.hpp"
#include "caf/mixin/requester.hpp"
#include "caf/mixin/sender.hpp"
#include "caf/mixin/sender.hpp"
#include "caf/scheduled_actor.hpp"
#include "caf/scheduled_actor.hpp"
...
@@ -27,6 +28,8 @@
...
@@ -27,6 +28,8 @@
namespace
caf
{
namespace
caf
{
/// Decorates a pointer to a @ref scheduled_actor with a statically typed actor
/// interface.
template
<
class
...
Sigs
>
template
<
class
...
Sigs
>
class
typed_actor_view
:
public
extend
<
typed_actor_view_base
,
class
typed_actor_view
:
public
extend
<
typed_actor_view_base
,
typed_actor_view
<
Sigs
...
>>::
template
typed_actor_view
<
Sigs
...
>>::
template
...
@@ -46,30 +49,129 @@ public:
...
@@ -46,30 +49,129 @@ public:
return
*
this
;
return
*
this
;
}
}
/****************************************************************************
// -- spawn functions --------------------------------------------------------
* spawn actors *
****************************************************************************/
/// @copydoc local_actor::spawn
template
<
class
T
,
spawn_options
Os
=
no_spawn_options
,
class
...
Ts
>
template
<
class
T
,
spawn_options
Os
=
no_spawn_options
,
class
...
Ts
>
typename
infer_handle_from_class
<
T
>::
type
typename
infer_handle_from_class
<
T
>::
type
spawn
(
Ts
&&
...
xs
)
{
spawn
(
Ts
&&
...
xs
)
{
return
self_
->
spawn
<
T
,
Os
>
(
std
::
forward
<
Ts
>
(
xs
)...);
return
self_
->
spawn
<
T
,
Os
>
(
std
::
forward
<
Ts
>
(
xs
)...);
}
}
/// @copydoc local_actor::spawn
template
<
class
T
,
spawn_options
Os
=
no_spawn_options
>
template
<
class
T
,
spawn_options
Os
=
no_spawn_options
>
infer_handle_from_state_t
<
T
>
spawn
()
{
infer_handle_from_state_t
<
T
>
spawn
()
{
return
self_
->
spawn
<
T
,
Os
>
();
return
self_
->
spawn
<
T
,
Os
>
();
}
}
/// @copydoc local_actor::spawn
template
<
spawn_options
Os
=
no_spawn_options
,
class
F
,
class
...
Ts
>
template
<
spawn_options
Os
=
no_spawn_options
,
class
F
,
class
...
Ts
>
typename
infer_handle_from_fun
<
F
>::
type
typename
infer_handle_from_fun
<
F
>::
type
spawn
(
F
fun
,
Ts
&&
...
xs
)
{
spawn
(
F
fun
,
Ts
&&
...
xs
)
{
return
self_
->
spawn
<
Os
>
(
std
::
move
(
fun
),
std
::
forward
<
Ts
>
(
xs
)...);
return
self_
->
spawn
<
Os
>
(
std
::
move
(
fun
),
std
::
forward
<
Ts
>
(
xs
)...);
}
}
/****************************************************************************
// -- state modifiers --------------------------------------------------------
* miscellaneous actor operations *
****************************************************************************/
/// @copydoc scheduled_actor::quit
void
quit
(
error
x
=
error
{})
{
self_
->
quit
(
std
::
move
(
x
));
}
// -- properties -------------------------------------------------------------
/// @copydoc scheduled_actor::mailbox
auto
&
mailbox
()
noexcept
{
return
self_
->
mailbox
();
}
// -- event handlers ---------------------------------------------------------
/// @copydoc scheduled_actor::set_default_handler
template
<
class
Fun
>
void
set_default_handler
(
Fun
&&
fun
)
{
self_
->
set_default_handler
(
std
::
forward
<
Fun
>
(
fun
));
}
/// @copydoc scheduled_actor::set_error_handler
template
<
class
Fun
>
void
set_error_handler
(
Fun
&&
fun
)
{
self_
->
set_error_handler
(
std
::
forward
<
Fun
>
(
fun
));
}
/// @copydoc scheduled_actor::set_down_handler
template
<
class
Fun
>
void
set_down_handler
(
Fun
&&
fun
)
{
self_
->
set_down_handler
(
std
::
forward
<
Fun
>
(
fun
));
}
/// @copydoc scheduled_actor::set_node_down_handler
template
<
class
Fun
>
void
set_node_down_handler
(
Fun
&&
fun
)
{
self_
->
set_node_down_handler
(
std
::
forward
<
Fun
>
(
fun
));
}
/// @copydoc scheduled_actor::set_exit_handler
template
<
class
Fun
>
void
set_exit_handler
(
Fun
&&
fun
)
{
self_
->
set_exit_handler
(
std
::
forward
<
Fun
>
(
fun
));
}
#ifndef CAF_NO_EXCEPTIONS
/// @copydoc scheduled_actor::set_exception_handler
template
<
class
Fun
>
void
set_exception_handler
(
Fun
&&
fun
)
{
self_
->
set_exception_handler
(
std
::
forward
<
Fun
>
(
fun
));
}
#endif // CAF_NO_EXCEPTIONS
// -- linking and monitoring -------------------------------------------------
/// @copydoc monitorable_actor::link_to
template
<
class
ActorHandle
>
void
link_to
(
const
ActorHandle
&
x
)
{
self_
->
link_to
(
x
);
}
/// @copydoc monitorable_actor::unlink_from
template
<
class
ActorHandle
>
void
unlink_from
(
const
ActorHandle
&
x
)
{
self_
->
unlink_from
(
x
);
}
/// @copydoc local_actor::monitor
void
monitor
(
const
node_id
&
node
)
{
self_
->
monitor
(
node
);
}
/// @copydoc local_actor::monitor
template
<
message_priority
P
=
message_priority
::
normal
,
class
Handle
>
void
monitor
(
const
Handle
&
whom
)
{
self_
->
monitor
(
whom
);
}
/// @copydoc local_actor::demonitor
void
demonitor
(
const
node_id
&
node
)
{
self_
->
demonitor
(
node
);
}
/// @copydoc local_actor::demonitor
template
<
class
Handle
>
void
demonitor
(
const
Handle
&
whom
)
{
self_
->
demonitor
(
whom
);
}
// -- sending asynchronous messages ------------------------------------------
/// @copydoc local_actor::send_exit
template
<
class
ActorHandle
>
void
send_exit
(
const
ActorHandle
&
whom
,
error
reason
)
{
self_
->
send_exit
(
whom
,
std
::
move
(
reason
));
}
// -- miscellaneous actor operations -----------------------------------------
execution_unit
*
context
()
const
{
execution_unit
*
context
()
const
{
return
self_
->
context
();
return
self_
->
context
();
...
@@ -93,16 +195,6 @@ public:
...
@@ -93,16 +195,6 @@ public:
return
self_
->
make_response_promise
<
Ts
...
>
();
return
self_
->
make_response_promise
<
Ts
...
>
();
}
}
template
<
message_priority
P
=
message_priority
::
normal
,
class
Handle
=
actor
>
void
monitor
(
const
Handle
&
x
)
{
self_
->
monitor
<
P
>
(
x
);
}
template
<
class
T
>
void
demonitor
(
const
T
&
x
)
{
self_
->
demonitor
(
x
);
}
message_id
new_request_id
(
message_priority
mp
)
{
message_id
new_request_id
(
message_priority
mp
)
{
return
self_
->
new_request_id
(
mp
);
return
self_
->
new_request_id
(
mp
);
}
}
...
...
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