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
e8234af5
Commit
e8234af5
authored
Jun 11, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simply functor_attachable implementation
parent
35737b2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
30 deletions
+20
-30
libcaf_core/caf/detail/functor_attachable.hpp
libcaf_core/caf/detail/functor_attachable.hpp
+20
-30
No files found.
libcaf_core/caf/detail/functor_attachable.hpp
View file @
e8234af5
...
@@ -11,41 +11,31 @@
...
@@ -11,41 +11,31 @@
namespace
caf
::
detail
{
namespace
caf
::
detail
{
template
<
class
F
,
int
Args
=
tl_size
<
typename
get_callable_trait
<
F
>
::
arg_types
>::
value
>
struct
functor_attachable
:
attachable
{
static_assert
(
Args
==
1
||
Args
==
2
,
"Only 0, 1 or 2 arguments for F are supported"
);
F
functor_
;
functor_attachable
(
F
arg
)
:
functor_
(
std
::
move
(
arg
))
{
// nop
}
void
actor_exited
(
const
error
&
fail_state
,
execution_unit
*
)
override
{
functor_
(
fail_state
);
}
static
constexpr
size_t
token_type
=
attachable
::
token
::
anonymous
;
};
template
<
class
F
>
template
<
class
F
>
struct
functor_attachable
<
F
,
2
>
:
attachable
{
class
functor_attachable
:
public
attachable
{
F
functor_
;
public:
functor_attachable
(
F
arg
)
:
functor_
(
std
::
move
(
arg
))
{
static
constexpr
size_t
num_args
// nop
=
tl_size
<
typename
get_callable_trait
<
F
>::
arg_types
>::
value
;
}
void
actor_exited
(
const
error
&
x
,
execution_unit
*
y
)
override
{
functor_
(
x
,
y
);
}
};
template
<
class
F
>
static_assert
(
num_args
<
3
,
"Only 0, 1 or 2 arguments for F are supported"
);
struct
functor_attachable
<
F
,
0
>
:
attachable
{
F
functor_
;
explicit
functor_attachable
(
F
fn
)
:
fn_
(
std
::
move
(
fn
))
{
functor_attachable
(
F
arg
)
:
functor_
(
std
::
move
(
arg
))
{
// nop
// nop
}
}
void
actor_exited
(
const
error
&
,
execution_unit
*
)
override
{
functor_
();
void
actor_exited
(
const
error
&
fail_state
,
execution_unit
*
host
)
override
{
if
constexpr
(
num_args
==
0
)
fn_
();
else
if
constexpr
(
num_args
==
1
)
fn_
(
fail_state
);
else
fn_
(
fail_state
,
host
);
}
}
static
constexpr
size_t
token_type
=
attachable
::
token
::
anonymous
;
private:
F
fn_
;
};
};
}
// namespace caf::detail
}
// namespace caf::detail
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