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
854197b1
Commit
854197b1
authored
Aug 12, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `infer_handle_*` to separate header
parent
681e3f04
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
89 deletions
+130
-89
libcaf_core/caf/blocking_actor.hpp
libcaf_core/caf/blocking_actor.hpp
+2
-0
libcaf_core/caf/experimental/announce_actor_type.hpp
libcaf_core/caf/experimental/announce_actor_type.hpp
+2
-89
libcaf_core/caf/infer_handle.hpp
libcaf_core/caf/infer_handle.hpp
+126
-0
No files found.
libcaf_core/caf/blocking_actor.hpp
View file @
854197b1
...
...
@@ -46,6 +46,8 @@ class blocking_actor
:
public
extend
<
local_actor
,
blocking_actor
>::
with
<
mixin
::
sync_sender
<
blocking_response_handle_tag
>::
impl
>
{
public:
using
behavior_type
=
behavior
;
blocking_actor
();
~
blocking_actor
();
...
...
libcaf_core/caf/experimental/announce_actor_type.hpp
View file @
854197b1
...
...
@@ -24,8 +24,7 @@
#include "caf/actor.hpp"
#include "caf/actor_addr.hpp"
#include "caf/typed_behavior.hpp"
#include "caf/typed_event_based_actor.hpp"
#include "caf/infer_handle.hpp"
#include "caf/detail/singletons.hpp"
#include "caf/detail/type_traits.hpp"
...
...
@@ -34,89 +33,6 @@
namespace
caf
{
namespace
experimental
{
enum
class
spawn_mode
{
function
,
function_with_selfptr
,
clazz
};
template
<
spawn_mode
X
>
using
spawn_mode_token
=
std
::
integral_constant
<
spawn_mode
,
X
>
;
// default: dynamically typed actor without self pointer
template
<
class
Result
,
class
FirstArg
,
bool
FirstArgValid
=
std
::
is_base_of
<
local_actor
,
typename
std
::
remove_pointer
<
FirstArg
>
::
type
>::
value
>
struct
infer_handle_from_fun_impl
{
using
type
=
actor
;
using
impl
=
event_based_actor
;
using
behavior_type
=
behavior
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function
;
};
// dynamically typed actor returning a behavior
template
<
class
Impl
>
struct
infer_handle_from_fun_impl
<
void
,
Impl
*
,
true
>
{
using
type
=
actor
;
using
impl
=
Impl
;
using
behavior_type
=
behavior
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function_with_selfptr
;
};
// dynamically typed actor with self pointer
template
<
class
Impl
>
struct
infer_handle_from_fun_impl
<
behavior
,
Impl
*
,
true
>
{
using
type
=
actor
;
using
impl
=
Impl
;
using
behavior_type
=
behavior
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function_with_selfptr
;
};
// statically typed actor returning a behavior
template
<
class
...
Sigs
,
class
FirstArg
>
struct
infer_handle_from_fun_impl
<
typed_behavior
<
Sigs
...
>
,
FirstArg
,
false
>
{
using
type
=
typed_actor
<
Sigs
...
>
;
using
impl
=
typed_event_based_actor
<
Sigs
...
>
;
using
behavior_type
=
typed_behavior
<
Sigs
...
>
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function
;
};
// statically typed actor with self pointer
template
<
class
Result
,
class
...
Sigs
>
struct
infer_handle_from_fun_impl
<
Result
,
typed_event_based_actor
<
Sigs
...
>*
,
true
>
{
using
type
=
typed_actor
<
Sigs
...
>
;
using
impl
=
typed_event_based_actor
<
Sigs
...
>
;
using
behavior_type
=
typed_behavior
<
Sigs
...
>
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function_with_selfptr
;
};
template
<
class
F
,
class
Trait
=
typename
detail
::
get_callable_trait
<
F
>
::
type
>
struct
infer_handle_from_fun
{
using
result_type
=
typename
Trait
::
result_type
;
using
arg_types
=
typename
Trait
::
arg_types
;
using
first_arg
=
typename
detail
::
tl_head
<
arg_types
>::
type
;
using
delegate
=
infer_handle_from_fun_impl
<
result_type
,
first_arg
>
;
using
type
=
typename
delegate
::
type
;
using
impl
=
typename
delegate
::
impl
;
using
behavior_type
=
typename
delegate
::
behavior_type
;
using
fun_type
=
typename
Trait
::
fun_type
;
static
constexpr
spawn_mode
mode
=
delegate
::
mode
;
};
template
<
class
T
>
struct
infer_handle_from_behavior
{
using
type
=
actor
;
};
template
<
class
...
Sigs
>
struct
infer_handle_from_behavior
<
typed_behavior
<
Sigs
...
>>
{
using
type
=
typed_actor
<
Sigs
...
>
;
};
using
spawn_result
=
std
::
pair
<
actor_addr
,
std
::
set
<
std
::
string
>>
;
using
spawn_fun
=
std
::
function
<
spawn_result
(
message
)
>
;
...
...
@@ -176,10 +92,7 @@ spawn_fun make_spawn_fun() {
"all Ts must be lvalue references"
);
static_assert
(
std
::
is_base_of
<
local_actor
,
T
>::
value
,
"T is not derived from local_actor"
);
using
handle
=
typename
infer_handle_from_behavior
<
typename
T
::
behavior_type
>::
type
;
using
handle
=
typename
infer_handle_from_class
<
T
>::
type
;
using
pointer
=
intrusive_ptr
<
T
>
;
auto
factory
=
&
make_counted
<
T
,
Ts
...
>
;
return
[
=
](
message
msg
)
->
spawn_result
{
...
...
libcaf_core/caf/infer_handle.hpp
0 → 100644
View file @
854197b1
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_INFER_HANDLE_HPP
#define CAF_INFER_HANDLE_HPP
#include "caf/actor.hpp"
#include "caf/actor_addr.hpp"
#include "caf/typed_behavior.hpp"
#include "caf/typed_event_based_actor.hpp"
namespace
caf
{
enum
class
spawn_mode
{
function
,
function_with_selfptr
,
clazz
};
template
<
spawn_mode
X
>
using
spawn_mode_token
=
std
::
integral_constant
<
spawn_mode
,
X
>
;
// default: dynamically typed actor without self pointer
template
<
class
Result
,
class
FirstArg
,
bool
FirstArgValid
=
std
::
is_base_of
<
local_actor
,
typename
std
::
remove_pointer
<
FirstArg
>
::
type
>::
value
>
struct
infer_handle_from_fun_impl
{
using
type
=
actor
;
using
impl
=
event_based_actor
;
using
behavior_type
=
behavior
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function
;
};
// dynamically typed actor returning a behavior
template
<
class
Impl
>
struct
infer_handle_from_fun_impl
<
void
,
Impl
*
,
true
>
{
using
type
=
actor
;
using
impl
=
Impl
;
using
behavior_type
=
behavior
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function_with_selfptr
;
};
// dynamically typed actor with self pointer
template
<
class
Impl
>
struct
infer_handle_from_fun_impl
<
behavior
,
Impl
*
,
true
>
{
using
type
=
actor
;
using
impl
=
Impl
;
using
behavior_type
=
behavior
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function_with_selfptr
;
};
// statically typed actor returning a behavior
template
<
class
...
Sigs
,
class
FirstArg
>
struct
infer_handle_from_fun_impl
<
typed_behavior
<
Sigs
...
>
,
FirstArg
,
false
>
{
using
type
=
typed_actor
<
Sigs
...
>
;
using
impl
=
typed_event_based_actor
<
Sigs
...
>
;
using
behavior_type
=
typed_behavior
<
Sigs
...
>
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function
;
};
// statically typed actor with self pointer
template
<
class
Result
,
class
...
Sigs
>
struct
infer_handle_from_fun_impl
<
Result
,
typed_event_based_actor
<
Sigs
...
>*
,
true
>
{
using
type
=
typed_actor
<
Sigs
...
>
;
using
impl
=
typed_event_based_actor
<
Sigs
...
>
;
using
behavior_type
=
typed_behavior
<
Sigs
...
>
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function_with_selfptr
;
};
template
<
class
F
,
class
Trait
=
typename
detail
::
get_callable_trait
<
F
>
::
type
>
struct
infer_handle_from_fun
{
using
result_type
=
typename
Trait
::
result_type
;
using
arg_types
=
typename
Trait
::
arg_types
;
using
first_arg
=
typename
detail
::
tl_head
<
arg_types
>::
type
;
using
delegate
=
infer_handle_from_fun_impl
<
result_type
,
first_arg
>
;
using
type
=
typename
delegate
::
type
;
using
impl
=
typename
delegate
::
impl
;
using
behavior_type
=
typename
delegate
::
behavior_type
;
using
fun_type
=
typename
Trait
::
fun_type
;
static
constexpr
spawn_mode
mode
=
delegate
::
mode
;
};
template
<
class
T
>
struct
infer_handle_from_behavior
{
using
type
=
actor
;
};
template
<
class
...
Sigs
>
struct
infer_handle_from_behavior
<
typed_behavior
<
Sigs
...
>>
{
using
type
=
typed_actor
<
Sigs
...
>
;
};
template
<
class
T
>
struct
infer_handle_from_class
{
using
type
=
typename
infer_handle_from_behavior
<
typename
T
::
behavior_type
>::
type
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
clazz
;
};
}
// namespace caf
#endif // CAF_INFER_HANDLE_HPP
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