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
3d596c39
Commit
3d596c39
authored
Nov 06, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow functor attachables to have one or two args
parent
7478b485
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
10 deletions
+60
-10
libcaf_core/caf/abstract_actor.hpp
libcaf_core/caf/abstract_actor.hpp
+2
-10
libcaf_core/caf/detail/functor_attachable.hpp
libcaf_core/caf/detail/functor_attachable.hpp
+58
-0
No files found.
libcaf_core/caf/abstract_actor.hpp
View file @
3d596c39
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include "caf/abstract_channel.hpp"
#include "caf/abstract_channel.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/functor_attachable.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -90,16 +91,7 @@ class abstract_actor : public abstract_channel {
...
@@ -90,16 +91,7 @@ class abstract_actor : public abstract_channel {
*/
*/
template
<
class
F
>
template
<
class
F
>
void
attach_functor
(
F
f
)
{
void
attach_functor
(
F
f
)
{
struct
functor_attachable
:
attachable
{
attach
(
attachable_ptr
{
new
detail
::
functor_attachable
<
F
>
(
std
::
move
(
f
))});
F
m_functor
;
functor_attachable
(
F
arg
)
:
m_functor
(
std
::
move
(
arg
))
{
// nop
}
void
actor_exited
(
abstract_actor
*
,
uint32_t
reason
)
{
m_functor
(
reason
);
}
};
attach
(
attachable_ptr
{
new
functor_attachable
(
std
::
move
(
f
))});
}
}
/**
/**
...
...
libcaf_core/caf/detail/functor_attachable.hpp
0 → 100644
View file @
3d596c39
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2014 *
* 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 LICENCE_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_FUNCTOR_ATTACHABLE_HPP
#define CAF_FUNCTOR_ATTACHABLE_HPP
#include "caf/attachable.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/type_traits.hpp"
namespace
caf
{
namespace
detail
{
template
<
class
F
,
int
Args
=
tl_size
<
typename
get_callable_trait
<
F
>
::
arg_types
>::
value
>
struct
functor_attachable
:
attachable
{
static_assert
(
Args
==
2
,
"Only 1 and 2 arguments for F are supported"
);
F
m_functor
;
functor_attachable
(
F
arg
)
:
m_functor
(
std
::
move
(
arg
))
{
// nop
}
void
actor_exited
(
abstract_actor
*
self
,
uint32_t
reason
)
override
{
m_functor
(
self
,
reason
);
}
};
template
<
class
F
>
struct
functor_attachable
<
F
,
1
>
:
attachable
{
F
m_functor
;
functor_attachable
(
F
arg
)
:
m_functor
(
std
::
move
(
arg
))
{
// nop
}
void
actor_exited
(
abstract_actor
*
,
uint32_t
reason
)
override
{
m_functor
(
reason
);
}
};
}
// namespace detail
}
// namespace caf
#endif // CAF_FUNCTOR_ATTACHABLE_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