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
4a9ea16f
Commit
4a9ea16f
authored
Mar 11, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style nitpicks
parent
5bbd5b8a
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
203 additions
and
200 deletions
+203
-200
libcaf_core/caf/abstract_event_based_actor.hpp
libcaf_core/caf/abstract_event_based_actor.hpp
+8
-8
libcaf_core/caf/announce.hpp
libcaf_core/caf/announce.hpp
+26
-27
libcaf_core/caf/behavior.hpp
libcaf_core/caf/behavior.hpp
+3
-5
libcaf_core/caf/blocking_actor.hpp
libcaf_core/caf/blocking_actor.hpp
+10
-10
libcaf_core/caf/detail/default_uniform_type_info.hpp
libcaf_core/caf/detail/default_uniform_type_info.hpp
+26
-27
libcaf_core/caf/detail/memory.hpp
libcaf_core/caf/detail/memory.hpp
+2
-2
libcaf_core/caf/detail/message_case_builder.hpp
libcaf_core/caf/detail/message_case_builder.hpp
+3
-3
libcaf_core/caf/detail/singleton_mixin.hpp
libcaf_core/caf/detail/singleton_mixin.hpp
+1
-1
libcaf_core/caf/detail/tuple_vals.hpp
libcaf_core/caf/detail/tuple_vals.hpp
+2
-2
libcaf_core/caf/intrusive_ptr.hpp
libcaf_core/caf/intrusive_ptr.hpp
+2
-2
libcaf_core/caf/make_counted.hpp
libcaf_core/caf/make_counted.hpp
+4
-4
libcaf_core/caf/message.hpp
libcaf_core/caf/message.hpp
+1
-1
libcaf_core/caf/message_builder.hpp
libcaf_core/caf/message_builder.hpp
+2
-2
libcaf_core/caf/message_handler.hpp
libcaf_core/caf/message_handler.hpp
+8
-9
libcaf_core/caf/mixin/actor_widget.hpp
libcaf_core/caf/mixin/actor_widget.hpp
+1
-1
libcaf_core/caf/mixin/functor_based.hpp
libcaf_core/caf/mixin/functor_based.hpp
+5
-7
libcaf_core/caf/on.hpp
libcaf_core/caf/on.hpp
+3
-3
libcaf_core/caf/sb_actor.hpp
libcaf_core/caf/sb_actor.hpp
+4
-3
libcaf_core/caf/spawn.hpp
libcaf_core/caf/spawn.hpp
+34
-34
libcaf_core/caf/spawn_fwd.hpp
libcaf_core/caf/spawn_fwd.hpp
+17
-15
libcaf_core/caf/string_algorithms.hpp
libcaf_core/caf/string_algorithms.hpp
+5
-3
libcaf_core/caf/uniform_type_info.hpp
libcaf_core/caf/uniform_type_info.hpp
+2
-2
libcaf_core/src/group_manager.cpp
libcaf_core/src/group_manager.cpp
+2
-2
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+6
-5
libcaf_core/src/uniform_type_info_map.cpp
libcaf_core/src/uniform_type_info_map.cpp
+6
-4
libcaf_io/caf/io/middleman.hpp
libcaf_io/caf/io/middleman.hpp
+2
-2
libcaf_io/caf/io/spawn_io.hpp
libcaf_io/caf/io/spawn_io.hpp
+5
-5
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+3
-3
unit_testing/test_atom.cpp
unit_testing/test_atom.cpp
+5
-3
unit_testing/test_match.cpp
unit_testing/test_match.cpp
+3
-3
unit_testing/test_message.cpp
unit_testing/test_message.cpp
+2
-2
No files found.
libcaf_core/caf/abstract_event_based_actor.hpp
View file @
4a9ea16f
...
...
@@ -66,14 +66,14 @@ class abstract_event_based_actor : public
!
std
::
is_same
<
keep_behavior_t
,
typename
std
::
decay
<
T
>::
type
>::
value
,
void
>::
type
become
(
T
&&
arg
,
Ts
&&
...
arg
s
)
{
behavior_type
bhvr
{
std
::
forward
<
T
>
(
arg
),
std
::
forward
<
Ts
>
(
arg
s
)...};
become
(
T
&&
x
,
Ts
&&
...
x
s
)
{
behavior_type
bhvr
{
std
::
forward
<
T
>
(
x
),
std
::
forward
<
Ts
>
(
x
s
)...};
this
->
do_become
(
std
::
move
(
unbox
(
bhvr
)),
true
);
}
template
<
class
...
Ts
>
void
become
(
const
keep_behavior_t
&
,
Ts
&&
...
arg
s
)
{
behavior_type
bhvr
{
std
::
forward
<
Ts
>
(
arg
s
)...};
void
become
(
const
keep_behavior_t
&
,
Ts
&&
...
x
s
)
{
behavior_type
bhvr
{
std
::
forward
<
Ts
>
(
x
s
)...};
this
->
do_become
(
std
::
move
(
unbox
(
bhvr
)),
false
);
}
...
...
@@ -83,12 +83,12 @@ class abstract_event_based_actor : public
private:
template
<
class
...
Ts
>
static
behavior
&
unbox
(
typed_behavior
<
Ts
...
>&
arg
)
{
return
arg
.
unbox
();
static
behavior
&
unbox
(
typed_behavior
<
Ts
...
>&
x
)
{
return
x
.
unbox
();
}
static
inline
behavior
&
unbox
(
behavior
&
bhvr
)
{
return
bhvr
;
static
inline
behavior
&
unbox
(
behavior
&
x
)
{
return
x
;
}
};
...
...
libcaf_core/caf/announce.hpp
View file @
4a9ea16f
...
...
@@ -88,56 +88,55 @@ const uniform_type_info* announce(const std::type_info& tinfo,
// deals with member pointer
/**
* Creates meta information for a non-trivial
member `C`, whereas
*
`args` are the "sub-members" of `c_pt
r`.
* Creates meta information for a non-trivial
`Member`,
*
whereas `xs` are the "sub-members" of `Membe
r`.
* @see {@link announce_4.cpp announce example 4}
*/
template
<
class
C
,
class
Parent
,
class
...
Ts
>
std
::
pair
<
C
Parent
::*
,
detail
::
abstract_uniform_type_info
<
C
>*>
compound_member
(
C
Parent
::*
c_ptr
,
const
Ts
&
...
arg
s
)
{
return
{
c_ptr
,
new
detail
::
default_uniform_type_info
<
C
>
(
"???"
,
arg
s
...)};
template
<
class
Member
,
class
Parent
,
class
...
Ts
>
std
::
pair
<
Member
Parent
::*
,
detail
::
abstract_uniform_type_info
<
Member
>*>
compound_member
(
Member
Parent
::*
memptr
,
const
Ts
&
...
x
s
)
{
return
{
memptr
,
new
detail
::
default_uniform_type_info
<
Member
>
(
"???"
,
x
s
...)};
}
// deals with getter returning a mutable reference
/**
* Creates meta information for a non-trivial
member
accessed
* via
a getter returning a mutable reference, whereas
*
`args` are the "sub-members" of `c_pt
r`.
* Creates meta information for a non-trivial
`Member`
accessed
* via
the getter member function `getter` returning a mutable reference,
*
whereas `xs` are the "sub-members" of `Membe
r`.
* @see {@link announce_4.cpp announce example 4}
*/
template
<
class
C
,
class
Parent
,
class
...
Ts
>
std
::
pair
<
C
&
(
Parent
::*
)(),
detail
::
abstract_uniform_type_info
<
C
>*>
compound_member
(
C
&
(
Parent
::*
getter
)(),
const
Ts
&
...
arg
s
)
{
return
{
getter
,
new
detail
::
default_uniform_type_info
<
C
>
(
"???"
,
arg
s
...)};
template
<
class
Member
,
class
Parent
,
class
...
Ts
>
std
::
pair
<
Member
&
(
Parent
::*
)(),
detail
::
abstract_uniform_type_info
<
Member
>*>
compound_member
(
Member
&
(
Parent
::*
getter
)(),
const
Ts
&
...
x
s
)
{
return
{
getter
,
new
detail
::
default_uniform_type_info
<
Member
>
(
"???"
,
x
s
...)};
}
// deals with getter/setter pair
/**
* Creates meta information for a non-trivial
member
accessed
* via
a pair of getter and setter member function pointers, whereas
*
`args` are the "sub-members" of `c_pt
r`.
* Creates meta information for a non-trivial
`Member`
accessed
* via
the pair of getter and setter member function pointers `gspair`,
*
whereas `xs` are the "sub-members" of `Membe
r`.
* @see {@link announce_4.cpp announce example 4}
*/
template
<
class
Parent
,
class
GRes
,
class
SRes
,
class
SArg
,
class
...
Ts
>
std
::
pair
<
std
::
pair
<
GRes
(
Parent
::*
)()
const
,
SRes
(
Parent
::*
)(
SArg
)
>
,
detail
::
abstract_uniform_type_info
<
typename
std
::
decay
<
GRes
>::
type
>*>
detail
::
abstract_uniform_type_info
<
typename
std
::
decay
<
GRes
>::
type
>*>
compound_member
(
const
std
::
pair
<
GRes
(
Parent
::*
)()
const
,
SRes
(
Parent
::*
)(
SArg
)
>&
gspair
,
const
Ts
&
...
arg
s
)
{
const
Ts
&
...
x
s
)
{
using
mtype
=
typename
std
::
decay
<
GRes
>::
type
;
return
{
gspair
,
new
detail
::
default_uniform_type_info
<
mtype
>
(
"???"
,
arg
s
...)};
return
{
gspair
,
new
detail
::
default_uniform_type_info
<
mtype
>
(
"???"
,
x
s
...)};
}
/**
* Adds a new type mapping for `
C` to the type system
*
using `tname` as its uniform name
.
* Adds a new type mapping for `
T` to the type system using `tname`
*
as its uniform name and the list of member pointers `xs`
.
* @warning `announce` is **not** thead-safe!
*/
template
<
class
C
,
class
...
Ts
>
inline
const
uniform_type_info
*
announce
(
std
::
string
tname
,
const
Ts
&
...
arg
s
)
{
auto
ptr
=
new
detail
::
default_uniform_type_info
<
C
>
(
std
::
move
(
tname
),
arg
s
...);
return
announce
(
typeid
(
C
),
uniform_type_info_ptr
{
ptr
});
template
<
class
T
,
class
...
Ts
>
inline
const
uniform_type_info
*
announce
(
std
::
string
tname
,
const
Ts
&
...
x
s
)
{
auto
ptr
=
new
detail
::
default_uniform_type_info
<
T
>
(
std
::
move
(
tname
),
x
s
...);
return
announce
(
typeid
(
T
),
uniform_type_info_ptr
{
ptr
});
}
/**
...
...
libcaf_core/caf/behavior.hpp
View file @
4a9ea16f
...
...
@@ -111,12 +111,10 @@ class behavior {
}
/**
* Returns a value if `arg` was matched by one of the
* handler of this behavior, returns `nothing` otherwise.
* Runs this handler and returns its (optional) result.
*/
template
<
class
T
>
optional
<
message
>
operator
()(
T
&&
arg
)
{
return
(
m_impl
)
?
m_impl
->
invoke
(
std
::
forward
<
T
>
(
arg
))
:
none
;
inline
optional
<
message
>
operator
()(
message
&
arg
)
{
return
(
m_impl
)
?
m_impl
->
invoke
(
arg
)
:
none
;
}
/**
...
...
libcaf_core/caf/blocking_actor.hpp
View file @
4a9ea16f
...
...
@@ -65,10 +65,10 @@ class blocking_actor
std
::
function
<
bool
()
>
m_stmt
;
template
<
class
...
Ts
>
void
operator
()(
Ts
&&
...
arg
s
)
{
void
operator
()(
Ts
&&
...
x
s
)
{
static_assert
(
sizeof
...(
Ts
)
>
0
,
"operator() requires at least one argument"
);
behavior
bhvr
{
std
::
forward
<
Ts
>
(
arg
s
)...};
behavior
bhvr
{
std
::
forward
<
Ts
>
(
x
s
)...};
while
(
m_stmt
())
m_dq
(
bhvr
);
}
};
...
...
@@ -80,8 +80,8 @@ class blocking_actor
T
end
;
template
<
class
...
Ts
>
void
operator
()(
Ts
&&
...
arg
s
)
{
behavior
bhvr
{
std
::
forward
<
Ts
>
(
arg
s
)...};
void
operator
()(
Ts
&&
...
x
s
)
{
behavior
bhvr
{
std
::
forward
<
Ts
>
(
x
s
)...};
for
(;
begin
!=
end
;
++
begin
)
m_dq
(
bhvr
);
}
};
...
...
@@ -107,9 +107,9 @@ class blocking_actor
* matched by given behavior.
*/
template
<
class
...
Ts
>
void
receive
(
Ts
&&
...
arg
s
)
{
void
receive
(
Ts
&&
...
x
s
)
{
static_assert
(
sizeof
...(
Ts
),
"at least one argument required"
);
behavior
bhvr
{
std
::
forward
<
Ts
>
(
arg
s
)...};
behavior
bhvr
{
std
::
forward
<
Ts
>
(
x
s
)...};
dequeue
(
bhvr
);
}
...
...
@@ -118,8 +118,8 @@ class blocking_actor
* not cause a temporary behavior object per iteration.
*/
template
<
class
...
Ts
>
void
receive_loop
(
Ts
&&
...
arg
s
)
{
behavior
bhvr
{
std
::
forward
<
Ts
>
(
arg
s
)...};
void
receive_loop
(
Ts
&&
...
x
s
)
{
behavior
bhvr
{
std
::
forward
<
Ts
>
(
x
s
)...};
for
(;;)
dequeue
(
bhvr
);
}
...
...
@@ -182,8 +182,8 @@ class blocking_actor
* ~~~
*/
template
<
class
...
Ts
>
do_receive_helper
do_receive
(
Ts
&&
...
arg
s
)
{
return
{
make_dequeue_callback
(),
behavior
{
std
::
forward
<
Ts
>
(
arg
s
)...}};
do_receive_helper
do_receive
(
Ts
&&
...
x
s
)
{
return
{
make_dequeue_callback
(),
behavior
{
std
::
forward
<
Ts
>
(
x
s
)...}};
}
/**
...
...
libcaf_core/caf/detail/default_uniform_type_info.hpp
View file @
4a9ea16f
...
...
@@ -475,9 +475,9 @@ class default_uniform_type_info : public detail::abstract_uniform_type_info<T> {
using
super
=
detail
::
abstract_uniform_type_info
<
T
>
;
template
<
class
...
Ts
>
default_uniform_type_info
(
std
::
string
tname
,
Ts
&&
...
arg
s
)
default_uniform_type_info
(
std
::
string
tname
,
Ts
&&
...
x
s
)
:
super
(
std
::
move
(
tname
))
{
push_back
(
std
::
forward
<
Ts
>
(
arg
s
)...);
push_back
(
std
::
forward
<
Ts
>
(
x
s
)...);
}
default_uniform_type_info
(
std
::
string
tname
)
:
super
(
std
::
move
(
tname
))
{
...
...
@@ -525,46 +525,45 @@ class default_uniform_type_info : public detail::abstract_uniform_type_info<T> {
}
template
<
class
R
,
class
C
,
class
...
Ts
>
void
push_back
(
R
C
::*
memptr
,
Ts
&&
...
arg
s
)
{
void
push_back
(
R
C
::*
memptr
,
Ts
&&
...
x
s
)
{
m_members
.
push_back
(
new_member_tinfo
(
memptr
));
push_back
(
std
::
forward
<
Ts
>
(
arg
s
)...);
push_back
(
std
::
forward
<
Ts
>
(
x
s
)...);
}
// pr.first = member pointer
// pr.second = meta object to handle pr.first
template
<
class
R
,
class
C
,
class
...
Ts
>
void
push_back
(
const
std
::
pair
<
R
C
::*
,
detail
::
abstract_uniform_type_info
<
R
>*>&
pr
,
Ts
&&
...
arg
s
)
{
m_members
.
push_back
(
new_member_tinfo
(
pr
.
first
,
uniform_type_info_ptr
(
pr
.
second
)));
push_back
(
std
::
forward
<
Ts
>
(
arg
s
)...);
void
push_back
(
const
std
::
pair
<
R
C
::*
,
detail
::
abstract_uniform_type_info
<
R
>*>&
pr
,
Ts
&&
...
x
s
)
{
m_members
.
push_back
(
new_member_tinfo
(
pr
.
first
,
uniform_type_info_ptr
(
pr
.
second
)));
push_back
(
std
::
forward
<
Ts
>
(
x
s
)...);
}
// pr.first =
getter / setter pai
r
// pr.second =
meta object to handle pr.firs
t
// pr.first =
const-qualified gette
r
// pr.second =
setter with one argumen
t
template
<
class
GR
,
typename
SR
,
typename
ST
,
typename
C
,
class
...
Ts
>
void
push_back
(
const
std
::
pair
<
GR
(
C
::*
)()
const
,
// const-qualified getter
SR
(
C
::*
)(
ST
)
// setter with one argument
>&
pr
,
Ts
&&
...
args
)
{
void
push_back
(
const
std
::
pair
<
GR
(
C
::*
)()
const
,
SR
(
C
::*
)(
ST
)
>&
pr
,
Ts
&&
...
xs
)
{
m_members
.
push_back
(
new_member_tinfo
(
pr
.
first
,
pr
.
second
));
push_back
(
std
::
forward
<
Ts
>
(
arg
s
)...);
push_back
(
std
::
forward
<
Ts
>
(
x
s
)...);
}
// pr.first =
getter / setter pair
// pr.second =
meta object to handle pr.first
// pr.first =
pair of const-qualified getter and setter with one argument
// pr.second =
uniform type info pointer
template
<
class
GR
,
typename
SR
,
typename
ST
,
typename
C
,
class
...
Ts
>
void
push_back
(
const
std
::
pair
<
std
::
pair
<
GR
(
C
::*
)()
const
,
// const-qualified getter
SR
(
C
::*
)(
ST
)
// setter with one argument
>
,
void
push_back
(
const
std
::
pair
<
std
::
pair
<
GR
(
C
::*
)()
const
,
SR
(
C
::*
)(
ST
)
>
,
detail
::
abstract_uniform_type_info
<
typename
std
::
decay
<
GR
>::
type
>*>&
pr
,
Ts
&&
...
args
)
{
typename
std
::
decay
<
GR
>::
type
>*
>&
pr
,
Ts
&&
...
xs
)
{
m_members
.
push_back
(
new_member_tinfo
(
pr
.
first
.
first
,
pr
.
first
.
second
,
uniform_type_info_ptr
(
pr
.
second
)));
push_back
(
std
::
forward
<
Ts
>
(
arg
s
)...);
push_back
(
std
::
forward
<
Ts
>
(
x
s
)...);
}
std
::
vector
<
uniform_type_info_ptr
>
m_members
;
...
...
libcaf_core/caf/detail/memory.hpp
View file @
4a9ea16f
...
...
@@ -88,14 +88,14 @@ class memory {
// Allocates storage, initializes a new object, and returns the new instance.
template
<
class
T
,
class
...
Ts
>
static
T
*
create
(
Ts
&&
...
arg
s
)
{
static
T
*
create
(
Ts
&&
...
x
s
)
{
using
embedded_t
=
typename
std
::
conditional
<
T
::
memory_cache_flag
==
provides_embedding
,
rc_storage
<
T
>
,
T
>::
type
;
return
unbox_rc_storage
(
new
embedded_t
(
std
::
forward
<
Ts
>
(
arg
s
)...));
return
unbox_rc_storage
(
new
embedded_t
(
std
::
forward
<
Ts
>
(
x
s
)...));
}
static
inline
memory_cache
*
get_cache_map_entry
(
const
std
::
type_info
*
)
{
...
...
libcaf_core/caf/detail/message_case_builder.hpp
View file @
4a9ea16f
...
...
@@ -97,9 +97,9 @@ class message_case_pair_builder : public message_case_builder {
struct
tuple_maker
{
template
<
class
...
Ts
>
inline
auto
operator
()(
Ts
&&
...
arg
s
)
->
decltype
(
std
::
make_tuple
(
std
::
forward
<
Ts
>
(
arg
s
)...))
{
return
std
::
make_tuple
(
std
::
forward
<
Ts
>
(
arg
s
)...);
inline
auto
operator
()(
Ts
&&
...
x
s
)
->
decltype
(
std
::
make_tuple
(
std
::
forward
<
Ts
>
(
x
s
)...))
{
return
std
::
make_tuple
(
std
::
forward
<
Ts
>
(
x
s
)...);
}
};
...
...
libcaf_core/caf/detail/singleton_mixin.hpp
View file @
4a9ea16f
...
...
@@ -53,7 +53,7 @@ class singleton_mixin : public Base {
protected:
template
<
class
...
Ts
>
singleton_mixin
(
Ts
&&
...
args
)
:
Base
(
std
::
forward
<
Ts
>
(
arg
s
)...)
{
singleton_mixin
(
Ts
&&
...
xs
)
:
Base
(
std
::
forward
<
Ts
>
(
x
s
)...)
{
// nop
}
...
...
libcaf_core/caf/detail/tuple_vals.hpp
View file @
4a9ea16f
...
...
@@ -80,8 +80,8 @@ class tuple_vals : public message_data {
tuple_vals
(
const
tuple_vals
&
)
=
default
;
template
<
class
...
Us
>
tuple_vals
(
Us
&&
...
arg
s
)
:
m_data
(
std
::
forward
<
Us
>
(
arg
s
)...),
tuple_vals
(
Us
&&
...
x
s
)
:
m_data
(
std
::
forward
<
Us
>
(
x
s
)...),
m_types
{{
tuple_vals_type_helper
<
Ts
>::
get
()...}}
{
// nop
}
...
...
libcaf_core/caf/intrusive_ptr.hpp
View file @
4a9ea16f
...
...
@@ -96,8 +96,8 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>>,
}
template
<
class
...
Ts
>
void
emplace
(
Ts
&&
...
arg
s
)
{
reset
(
new
T
(
std
::
forward
<
Ts
>
(
arg
s
)...));
void
emplace
(
Ts
&&
...
x
s
)
{
reset
(
new
T
(
std
::
forward
<
Ts
>
(
x
s
)...));
}
intrusive_ptr
&
operator
=
(
pointer
ptr
)
{
...
...
libcaf_core/caf/make_counted.hpp
View file @
4a9ea16f
...
...
@@ -38,8 +38,8 @@ typename std::enable_if<
detail
::
is_memory_cached
<
T
>::
value
,
intrusive_ptr
<
T
>
>::
type
make_counted
(
Ts
&&
...
arg
s
)
{
return
intrusive_ptr
<
T
>
(
detail
::
memory
::
create
<
T
>
(
std
::
forward
<
Ts
>
(
arg
s
)...),
make_counted
(
Ts
&&
...
x
s
)
{
return
intrusive_ptr
<
T
>
(
detail
::
memory
::
create
<
T
>
(
std
::
forward
<
Ts
>
(
x
s
)...),
false
);
}
...
...
@@ -53,8 +53,8 @@ typename std::enable_if<
!
detail
::
is_memory_cached
<
T
>::
value
,
intrusive_ptr
<
T
>
>::
type
make_counted
(
Ts
&&
...
arg
s
)
{
return
intrusive_ptr
<
T
>
(
new
T
(
std
::
forward
<
Ts
>
(
arg
s
)...),
false
);
make_counted
(
Ts
&&
...
x
s
)
{
return
intrusive_ptr
<
T
>
(
new
T
(
std
::
forward
<
Ts
>
(
x
s
)...),
false
);
}
}
// namespace caf
...
...
libcaf_core/caf/message.hpp
View file @
4a9ea16f
...
...
@@ -281,7 +281,7 @@ class message {
* }
* ~~~
*/
cli_res
extract_opts
(
std
::
vector
<
cli_arg
>
arg
s
)
const
;
cli_res
extract_opts
(
std
::
vector
<
cli_arg
>
x
s
)
const
;
/**
* Queries whether the element at position `p` is of type `T`.
...
...
libcaf_core/caf/message_builder.hpp
View file @
4a9ea16f
...
...
@@ -102,8 +102,8 @@ class message_builder {
/**
* @copydoc message::extract_opts
*/
inline
message
::
cli_res
extract_opts
(
std
::
vector
<
message
::
cli_arg
>
arg
s
)
const
{
return
to_message
().
extract_opts
(
std
::
move
(
arg
s
));
inline
message
::
cli_res
extract_opts
(
std
::
vector
<
message
::
cli_arg
>
x
s
)
const
{
return
to_message
().
extract_opts
(
std
::
move
(
x
s
));
}
/**
...
...
libcaf_core/caf/message_handler.hpp
View file @
4a9ea16f
...
...
@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_
PARTIAL_FUNCTION
_HPP
#define CAF_
PARTIAL_FUNCTION
_HPP
#ifndef CAF_
MESSAGE_HANDLER
_HPP
#define CAF_
MESSAGE_HANDLER
_HPP
#include <list>
#include <vector>
...
...
@@ -105,14 +105,13 @@ class message_handler {
/**
* Runs this handler and returns its (optional) result.
*/
template
<
class
T
>
optional
<
message
>
operator
()(
T
&&
arg
)
{
return
(
m_impl
)
?
m_impl
->
invoke
(
std
::
forward
<
T
>
(
arg
))
:
none
;
inline
optional
<
message
>
operator
()(
message
&
arg
)
{
return
(
m_impl
)
?
m_impl
->
invoke
(
arg
)
:
none
;
}
/**
* Returns a new handler that concatenates this handler
* with a new handler from `
arg
s...`.
* with a new handler from `
x
s...`.
*/
template
<
class
...
Ts
>
typename
std
::
conditional
<
...
...
@@ -122,10 +121,10 @@ class message_handler {
behavior
,
message_handler
>::
type
or_else
(
Ts
&&
...
arg
s
)
const
{
or_else
(
Ts
&&
...
x
s
)
const
{
// using a behavior is safe here, because we "cast"
// it back to a message_handler when appropriate
behavior
tmp
{
std
::
forward
<
Ts
>
(
arg
s
)...};
behavior
tmp
{
std
::
forward
<
Ts
>
(
x
s
)...};
if
(
!
tmp
)
{
return
*
this
;
}
...
...
@@ -141,4 +140,4 @@ class message_handler {
}
// namespace caf
#endif // CAF_
PARTIAL_FUNCTION
_HPP
#endif // CAF_
MESSAGE_HANDLER
_HPP
libcaf_core/caf/mixin/actor_widget.hpp
View file @
4a9ea16f
...
...
@@ -55,7 +55,7 @@ class actor_widget : public Base {
};
template
<
typename
...
Ts
>
actor_widget
(
Ts
&&
...
args
)
:
Base
(
std
::
forward
<
Ts
>
(
arg
s
)...)
{
actor_widget
(
Ts
&&
...
xs
)
:
Base
(
std
::
forward
<
Ts
>
(
x
s
)...)
{
m_companion
=
make_counted
<
actor_companion
>
();
m_companion
->
on_enqueue
([
=
](
message_pointer
ptr
)
{
qApp
->
postEvent
(
this
,
new
event_type
(
std
::
move
(
ptr
)));
...
...
libcaf_core/caf/mixin/functor_based.hpp
View file @
4a9ea16f
...
...
@@ -94,16 +94,14 @@ class functor_based : public Base {
}
template
<
class
Token
,
typename
F
,
typename
T0
,
class
...
Ts
>
void
set
(
Token
t1
,
std
::
true_type
t2
,
F
fun
,
T0
&&
arg0
,
Ts
&&
...
args
)
{
set
(
t1
,
t2
,
std
::
bind
(
fun
,
std
::
placeholders
::
_1
,
std
::
forward
<
T0
>
(
arg0
),
std
::
forward
<
Ts
>
(
args
)...));
void
set
(
Token
t1
,
std
::
true_type
t2
,
F
fun
,
T0
&&
x
,
Ts
&&
...
xs
)
{
set
(
t1
,
t2
,
std
::
bind
(
fun
,
std
::
placeholders
::
_1
,
std
::
forward
<
T0
>
(
x
),
std
::
forward
<
Ts
>
(
xs
)...));
}
template
<
class
Token
,
typename
F
,
typename
T0
,
class
...
Ts
>
void
set
(
Token
t1
,
std
::
false_type
t2
,
F
fun
,
T0
&&
arg0
,
Ts
&&
...
args
)
{
set
(
t1
,
t2
,
std
::
bind
(
fun
,
std
::
forward
<
T0
>
(
arg0
),
std
::
forward
<
Ts
>
(
args
)...));
void
set
(
Token
t1
,
std
::
false_type
t2
,
F
fun
,
T0
&&
x
,
Ts
&&
...
xs
)
{
set
(
t1
,
t2
,
std
::
bind
(
fun
,
std
::
forward
<
T0
>
(
x
),
std
::
forward
<
Ts
>
(
xs
)...));
}
};
...
...
libcaf_core/caf/on.hpp
View file @
4a9ea16f
...
...
@@ -151,15 +151,15 @@ auto to_guard(const atom_constant<V>&) -> decltype(to_guard(V)) {
* Returns a generator for `match_case` objects.
*/
template
<
class
...
Ts
>
auto
on
(
const
Ts
&
...
arg
s
)
auto
on
(
const
Ts
&
...
x
s
)
->
detail
::
advanced_match_case_builder
<
detail
::
type_list
<
decltype
(
to_guard
(
arg
s
))...
decltype
(
to_guard
(
x
s
))...
>
,
detail
::
type_list
<
typename
detail
::
pattern_type
<
typename
std
::
decay
<
Ts
>::
type
>::
type
...
>
>
{
return
{
detail
::
variadic_ctor
{},
to_guard
(
arg
s
)...};
return
{
detail
::
variadic_ctor
{},
to_guard
(
x
s
)...};
}
/**
...
...
libcaf_core/caf/sb_actor.hpp
View file @
4a9ea16f
...
...
@@ -50,8 +50,9 @@ public:
using
combined_type
=
sb_actor
;
template
<
class
...
Ts
>
sb_actor
(
Ts
&&
...
args
)
:
Base
(
std
::
forward
<
Ts
>
(
args
)...)
{}
sb_actor
(
Ts
&&
...
xs
)
:
Base
(
std
::
forward
<
Ts
>
(
xs
)...)
{
// nop
}
};
}
// namespace caf
...
...
libcaf_core/caf/spawn.hpp
View file @
4a9ea16f
...
...
@@ -38,14 +38,14 @@ namespace caf {
class
execution_unit
;
/**
* Returns a newly spawned instance of type `C` using `
arg
s...` as constructor
* Returns a newly spawned instance of type `C` using `
x
s...` as constructor
* arguments. The instance will be added to the job list of `host`. However,
* before the instance is launched, `before_launch_fun` will be called, e.g.,
* to join a group before the actor is running.
*/
template
<
class
C
,
spawn_options
Os
,
class
BeforeLaunch
,
class
...
Ts
>
intrusive_ptr
<
C
>
spawn_impl
(
execution_unit
*
host
,
BeforeLaunch
before_launch_fun
,
Ts
&&
...
arg
s
)
{
BeforeLaunch
before_launch_fun
,
Ts
&&
...
x
s
)
{
static_assert
(
!
std
::
is_base_of
<
blocking_actor
,
C
>::
value
||
has_blocking_api_flag
(
Os
),
"C is derived from blocking_actor but "
...
...
@@ -53,7 +53,7 @@ intrusive_ptr<C> spawn_impl(execution_unit* host,
static_assert
(
is_unbound
(
Os
),
"top-level spawns cannot have monitor or link flag"
);
CAF_LOGF_TRACE
(
""
);
auto
ptr
=
make_counted
<
C
>
(
std
::
forward
<
Ts
>
(
arg
s
)...);
auto
ptr
=
make_counted
<
C
>
(
std
::
forward
<
Ts
>
(
x
s
)...);
CAF_LOGF_DEBUG
(
"spawned actor with ID "
<<
ptr
->
id
());
CAF_PUSH_AID
(
ptr
->
id
());
if
(
has_priority_aware_flag
(
Os
))
{
...
...
@@ -104,9 +104,9 @@ spawn_fwd(typename std::remove_reference<T>::type&& arg) noexcept {
*/
template
<
class
C
,
spawn_options
Os
,
typename
BeforeLaunch
,
class
...
Ts
>
intrusive_ptr
<
C
>
spawn_class
(
execution_unit
*
host
,
BeforeLaunch
before_launch_fun
,
Ts
&&
...
arg
s
)
{
BeforeLaunch
before_launch_fun
,
Ts
&&
...
x
s
)
{
return
spawn_impl
<
C
,
Os
>
(
host
,
before_launch_fun
,
spawn_fwd
<
Ts
>
(
arg
s
)...);
spawn_fwd
<
Ts
>
(
x
s
)...);
}
/**
...
...
@@ -115,7 +115,7 @@ intrusive_ptr<C> spawn_class(execution_unit* host,
* selects a proper implementation class and then delegates to `spawn_class`.
*/
template
<
spawn_options
Os
,
typename
BeforeLaunch
,
typename
F
,
class
...
Ts
>
actor
spawn_functor
(
execution_unit
*
eu
,
BeforeLaunch
cb
,
F
fun
,
Ts
&&
...
arg
s
)
{
actor
spawn_functor
(
execution_unit
*
eu
,
BeforeLaunch
cb
,
F
fun
,
Ts
&&
...
x
s
)
{
using
trait
=
typename
detail
::
get_callable_trait
<
F
>::
type
;
using
arg_types
=
typename
trait
::
arg_types
;
using
first_arg
=
typename
detail
::
tl_head
<
arg_types
>::
type
;
...
...
@@ -138,7 +138,7 @@ actor spawn_functor(execution_unit* eu, BeforeLaunch cb, F fun, Ts&&... args) {
"non-blocking functor-based actors "
"cannot be spawned using the blocking_api flag"
);
using
impl_class
=
typename
base_class
::
functor_based
;
return
spawn_class
<
impl_class
,
Os
>
(
eu
,
cb
,
fun
,
std
::
forward
<
Ts
>
(
arg
s
)...);
return
spawn_class
<
impl_class
,
Os
>
(
eu
,
cb
,
fun
,
std
::
forward
<
Ts
>
(
x
s
)...);
}
/**
...
...
@@ -147,49 +147,49 @@ actor spawn_functor(execution_unit* eu, BeforeLaunch cb, F fun, Ts&&... args) {
*/
/**
* Returns a new actor of type `C` using `
arg
s...` as constructor
* Returns a new actor of type `C` using `
x
s...` as constructor
* arguments. The behavior of `spawn` can be modified by setting `Os`, e.g.,
* to opt-out of the cooperative scheduling.
*/
template
<
class
C
,
spawn_options
Os
=
no_spawn_options
,
class
...
Ts
>
actor
spawn
(
Ts
&&
...
arg
s
)
{
actor
spawn
(
Ts
&&
...
x
s
)
{
return
spawn_class
<
C
,
Os
>
(
nullptr
,
empty_before_launch_callback
{},
std
::
forward
<
Ts
>
(
arg
s
)...);
std
::
forward
<
Ts
>
(
x
s
)...);
}
/**
* Returns a new functor-based actor. The first argument must be the functor,
* the remainder of `
arg
s...` is used to invoke the functor.
* the remainder of `
x
s...` is used to invoke the functor.
* The behavior of `spawn` can be modified by setting `Os`, e.g.,
* to opt-out of the cooperative scheduling.
*/
template
<
spawn_options
Os
=
no_spawn_options
,
class
...
Ts
>
actor
spawn
(
Ts
&&
...
arg
s
)
{
actor
spawn
(
Ts
&&
...
x
s
)
{
static_assert
(
sizeof
...(
Ts
)
>
0
,
"too few arguments provided"
);
return
spawn_functor
<
Os
>
(
nullptr
,
empty_before_launch_callback
{},
std
::
forward
<
Ts
>
(
arg
s
)...);
std
::
forward
<
Ts
>
(
x
s
)...);
}
/**
* Returns a new actor that immediately, i.e., before this function
* returns, joins `grp` of type `C` using `
arg
s` as constructor arguments
* returns, joins `grp` of type `C` using `
x
s` as constructor arguments
*/
template
<
class
C
,
spawn_options
Os
=
no_spawn_options
,
class
...
Ts
>
actor
spawn_in_group
(
const
group
&
grp
,
Ts
&&
...
arg
s
)
{
actor
spawn_in_group
(
const
group
&
grp
,
Ts
&&
...
x
s
)
{
return
spawn_class
<
C
,
Os
>
(
nullptr
,
group_subscriber
{
grp
},
std
::
forward
<
Ts
>
(
arg
s
)...);
std
::
forward
<
Ts
>
(
x
s
)...);
}
/**
* Returns a new actor that immediately, i.e., before this function
* returns, joins `grp`. The first element of `
arg
s` must
* returns, joins `grp`. The first element of `
x
s` must
* be the functor, the remaining arguments its arguments.
*/
template
<
spawn_options
Os
=
no_spawn_options
,
class
...
Ts
>
actor
spawn_in_group
(
const
group
&
grp
,
Ts
&&
...
arg
s
)
{
actor
spawn_in_group
(
const
group
&
grp
,
Ts
&&
...
x
s
)
{
static_assert
(
sizeof
...(
Ts
)
>
0
,
"too few arguments provided"
);
return
spawn_functor
<
Os
>
(
nullptr
,
group_subscriber
{
grp
},
std
::
forward
<
Ts
>
(
arg
s
)...);
std
::
forward
<
Ts
>
(
x
s
)...);
}
/**
...
...
@@ -229,11 +229,11 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> {
using
one_arg_fun2
=
std
::
function
<
void
(
pointer
)
>
;
/**
* Creates a new instance from given functor, binding `
arg
s...`
* Creates a new instance from given functor, binding `
x
s...`
* to the functor.
*/
template
<
class
F
,
class
...
Ts
>
functor_based_typed_actor
(
F
fun
,
Ts
&&
...
arg
s
)
{
functor_based_typed_actor
(
F
fun
,
Ts
&&
...
x
s
)
{
using
trait
=
typename
detail
::
get_callable_trait
<
F
>::
type
;
using
arg_types
=
typename
trait
::
arg_types
;
using
result_type
=
typename
trait
::
result_type
;
...
...
@@ -243,7 +243,7 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> {
typename
detail
::
tl_head
<
arg_types
>::
type
,
pointer
>::
value
;
std
::
integral_constant
<
bool
,
returns_behavior
>
token1
;
std
::
integral_constant
<
bool
,
uses_first_arg
>
token2
;
set
(
token1
,
token2
,
std
::
move
(
fun
),
std
::
forward
<
Ts
>
(
arg
s
)...);
set
(
token1
,
token2
,
std
::
move
(
fun
),
std
::
forward
<
Ts
>
(
x
s
)...);
}
protected:
...
...
@@ -277,16 +277,16 @@ class functor_based_typed_actor : public typed_event_based_actor<Sigs...> {
// (false_type, false_type) is an invalid functor for typed actors
template
<
class
Token
,
typename
F
,
typename
T0
,
class
...
Ts
>
void
set
(
Token
t1
,
std
::
true_type
t2
,
F
fun
,
T0
&&
arg0
,
Ts
&&
...
arg
s
)
{
void
set
(
Token
t1
,
std
::
true_type
t2
,
F
fun
,
T0
&&
arg0
,
Ts
&&
...
x
s
)
{
set
(
t1
,
t2
,
std
::
bind
(
fun
,
std
::
placeholders
::
_1
,
std
::
forward
<
T0
>
(
arg0
),
std
::
forward
<
Ts
>
(
arg
s
)...));
std
::
forward
<
Ts
>
(
x
s
)...));
}
template
<
class
Token
,
typename
F
,
typename
T0
,
class
...
Ts
>
void
set
(
Token
t1
,
std
::
false_type
t2
,
F
fun
,
T0
&&
arg0
,
Ts
&&
...
arg
s
)
{
void
set
(
Token
t1
,
std
::
false_type
t2
,
F
fun
,
T0
&&
arg0
,
Ts
&&
...
x
s
)
{
set
(
t1
,
t2
,
std
::
bind
(
fun
,
std
::
forward
<
T0
>
(
arg0
),
std
::
forward
<
Ts
>
(
arg
s
)...));
std
::
bind
(
fun
,
std
::
forward
<
T0
>
(
arg0
),
std
::
forward
<
Ts
>
(
x
s
)...));
}
// we convert any of the three accepted signatures to this one
...
...
@@ -311,14 +311,14 @@ struct infer_typed_actor_base<void, typed_event_based_actor<Sigs...>*> {
};
/**
* Returns a new typed actor of type `C` using `
arg
s...` as
* Returns a new typed actor of type `C` using `
x
s...` as
* constructor arguments.
*/
template
<
class
C
,
spawn_options
Os
=
no_spawn_options
,
class
...
Ts
>
typename
actor_handle_from_signature_list
<
typename
C
::
signatures
>::
type
spawn_typed
(
Ts
&&
...
arg
s
)
{
spawn_typed
(
Ts
&&
...
x
s
)
{
return
spawn_class
<
C
,
Os
>
(
nullptr
,
empty_before_launch_callback
{},
std
::
forward
<
Ts
>
(
arg
s
)...);
std
::
forward
<
Ts
>
(
x
s
)...);
}
/**
...
...
@@ -331,7 +331,7 @@ typename infer_typed_actor_handle<
typename
detail
::
get_callable_trait
<
F
>::
arg_types
>::
type
>::
type
spawn_typed_functor
(
execution_unit
*
eu
,
BeforeLaunch
bl
,
F
fun
,
Ts
&&
...
arg
s
)
{
spawn_typed_functor
(
execution_unit
*
eu
,
BeforeLaunch
bl
,
F
fun
,
Ts
&&
...
x
s
)
{
using
impl
=
typename
infer_typed_actor_base
<
typename
detail
::
get_callable_trait
<
F
>::
result_type
,
...
...
@@ -339,12 +339,12 @@ spawn_typed_functor(execution_unit* eu, BeforeLaunch bl, F fun, Ts&&... args) {
typename
detail
::
get_callable_trait
<
F
>::
arg_types
>::
type
>::
type
;
return
spawn_class
<
impl
,
Os
>
(
eu
,
bl
,
fun
,
std
::
forward
<
Ts
>
(
arg
s
)...);
return
spawn_class
<
impl
,
Os
>
(
eu
,
bl
,
fun
,
std
::
forward
<
Ts
>
(
x
s
)...);
}
/**
* Returns a new typed actor from a functor. The first element
* of `
arg
s` must be the functor, the remaining arguments are used to
* of `
x
s` must be the functor, the remaining arguments are used to
* invoke the functor. This function delegates its arguments to
* `spawn_typed_functor`.
*/
...
...
@@ -355,9 +355,9 @@ typename infer_typed_actor_handle<
typename
detail
::
get_callable_trait
<
F
>::
arg_types
>::
type
>::
type
spawn_typed
(
F
fun
,
Ts
&&
...
arg
s
)
{
spawn_typed
(
F
fun
,
Ts
&&
...
x
s
)
{
return
spawn_typed_functor
<
Os
>
(
nullptr
,
empty_before_launch_callback
{},
std
::
move
(
fun
),
std
::
forward
<
Ts
>
(
arg
s
)...);
std
::
move
(
fun
),
std
::
forward
<
Ts
>
(
x
s
)...);
}
/** @} */
...
...
libcaf_core/caf/spawn_fwd.hpp
View file @
4a9ea16f
...
...
@@ -33,22 +33,26 @@ namespace caf {
template
<
class
C
,
spawn_options
Os
=
no_spawn_options
,
typename
BeforeLaunch
=
std
::
function
<
void
(
C
*
)>,
class
BeforeLaunch
=
std
::
function
<
void
(
C
*
)>,
class
...
Ts
>
intrusive_ptr
<
C
>
spawn_class
(
execution_unit
*
host
,
BeforeLaunch
before_launch_fun
,
Ts
&&
...
args
);
BeforeLaunch
before_launch_fun
,
Ts
&&
...
xs
);
template
<
spawn_options
Os
=
no_spawn_options
,
typename
BeforeLaunch
=
void
(
*
)(
abstract_actor
*
),
typename
F
=
behavior
(
*
)(),
class
...
Ts
>
actor
spawn_functor
(
execution_unit
*
host
,
BeforeLaunch
before_launch_fun
,
F
fun
,
Ts
&&
...
args
);
class
BeforeLaunch
=
void
(
*
)(
abstract_actor
*
),
class
F
=
behavior
(
*
)(),
class
...
Ts
>
actor
spawn_functor
(
execution_unit
*
host
,
BeforeLaunch
before_launch_fun
,
F
fun
,
Ts
&&
...
xs
);
class
group_subscriber
{
public:
inline
group_subscriber
(
const
group
&
grp
)
:
m_grp
(
grp
)
{}
inline
group_subscriber
(
const
group
&
grp
)
:
m_grp
(
grp
)
{
// nop
}
template
<
class
T
>
inline
void
operator
()(
T
*
ptr
)
const
{
...
...
@@ -56,9 +60,7 @@ class group_subscriber {
}
private:
group
m_grp
;
};
struct
empty_before_launch_callback
{
...
...
@@ -102,7 +104,7 @@ typename infer_typed_actor_handle<
typename
detail
::
get_callable_trait
<
F
>::
arg_types
>::
type
>::
type
spawn_typed_functor
(
execution_unit
*
,
BeforeLaunch
bl
,
F
fun
,
Ts
&&
...
arg
s
);
spawn_typed_functor
(
execution_unit
*
,
BeforeLaunch
bl
,
F
fun
,
Ts
&&
...
x
s
);
}
// namespace caf
...
...
libcaf_core/caf/string_algorithms.hpp
View file @
4a9ea16f
...
...
@@ -63,13 +63,15 @@ std::string join(const Container& c, const std::string& glue) {
}
// end of recursion
inline
void
splice
(
std
::
string
&
,
const
std
::
string
&
)
{
}
inline
void
splice
(
std
::
string
&
,
const
std
::
string
&
)
{
// nop
}
template
<
class
T
,
class
...
Ts
>
void
splice
(
std
::
string
&
str
,
const
std
::
string
&
glue
,
T
&&
arg
,
Ts
&&
...
arg
s
)
{
void
splice
(
std
::
string
&
str
,
const
std
::
string
&
glue
,
T
&&
arg
,
Ts
&&
...
x
s
)
{
str
+=
glue
;
str
+=
std
::
forward
<
T
>
(
arg
);
splice
(
str
,
glue
,
std
::
forward
<
Ts
>
(
arg
s
)...);
splice
(
str
,
glue
,
std
::
forward
<
Ts
>
(
x
s
)...);
}
template
<
ptrdiff_t
WhatSize
,
ptrdiff_t
WithSize
>
...
...
libcaf_core/caf/uniform_type_info.hpp
View file @
4a9ea16f
...
...
@@ -51,7 +51,7 @@ struct uniform_value_t {
};
template
<
class
T
,
class
...
Ts
>
uniform_value
make_uniform_value
(
const
uniform_type_info
*
uti
,
Ts
&&
...
arg
s
)
{
uniform_value
make_uniform_value
(
const
uniform_type_info
*
uti
,
Ts
&&
...
x
s
)
{
struct
container
:
uniform_value_t
{
T
value
;
container
(
const
uniform_type_info
*
ptr
,
T
arg
)
:
value
(
std
::
move
(
arg
))
{
...
...
@@ -62,7 +62,7 @@ uniform_value make_uniform_value(const uniform_type_info* uti, Ts&&... args) {
return
uniform_value
{
new
container
(
ti
,
value
)};
}
};
return
uniform_value
{
new
container
(
uti
,
T
(
std
::
forward
<
Ts
>
(
arg
s
)...))};
return
uniform_value
{
new
container
(
uti
,
T
(
std
::
forward
<
Ts
>
(
x
s
)...))};
}
/**
...
...
libcaf_core/src/group_manager.cpp
View file @
4a9ea16f
...
...
@@ -226,8 +226,8 @@ class local_group_proxy : public local_group {
using
super
=
local_group
;
template
<
class
...
Ts
>
local_group_proxy
(
actor
remote_broker
,
Ts
&&
...
arg
s
)
:
super
(
false
,
std
::
forward
<
Ts
>
(
arg
s
)...)
{
local_group_proxy
(
actor
remote_broker
,
Ts
&&
...
x
s
)
:
super
(
false
,
std
::
forward
<
Ts
>
(
x
s
)...)
{
CAF_REQUIRE
(
m_broker
==
invalid_actor
);
CAF_REQUIRE
(
remote_broker
!=
invalid_actor
);
m_broker
=
std
::
move
(
remote_broker
);
...
...
libcaf_core/src/message.cpp
View file @
4a9ea16f
...
...
@@ -120,7 +120,8 @@ message message::extract_impl(size_t start, message_handler handler) const {
auto
s
=
size
();
for
(
size_t
i
=
start
;
i
<
s
;
++
i
)
{
for
(
size_t
n
=
(
s
-
i
)
;
n
>
0
;
--
n
)
{
auto
res
=
handler
(
slice
(
i
,
n
));
auto
next_slice
=
slice
(
i
,
n
);
auto
res
=
handler
(
next_slice
);
if
(
res
)
{
std
::
vector
<
size_t
>
mapping
(
s
);
std
::
iota
(
mapping
.
begin
(),
mapping
.
end
(),
size_t
{
0
});
...
...
@@ -142,7 +143,7 @@ message message::extract(message_handler handler) const {
return
extract_impl
(
0
,
handler
);
}
message
::
cli_res
message
::
extract_opts
(
std
::
vector
<
cli_arg
>
cliarg
s
)
const
{
message
::
cli_res
message
::
extract_opts
(
std
::
vector
<
cli_arg
>
x
s
)
const
{
std
::
set
<
std
::
string
>
opts
;
cli_arg
dummy
{
"help,h"
,
""
};
std
::
map
<
std
::
string
,
cli_arg
*>
shorts
;
...
...
@@ -150,7 +151,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const {
shorts
[
"-h"
]
=
&
dummy
;
shorts
[
"-?"
]
=
&
dummy
;
longs
[
"--help"
]
=
&
dummy
;
for
(
auto
&
cliarg
:
cliarg
s
)
{
for
(
auto
&
cliarg
:
x
s
)
{
std
::
vector
<
std
::
string
>
s
;
split
(
s
,
cliarg
.
name
,
is_any_of
(
","
),
token_compress_on
);
if
(
s
.
size
()
==
2
&&
s
.
back
().
size
()
==
1
)
{
...
...
@@ -225,7 +226,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const {
}
});
size_t
name_width
=
0
;
for
(
auto
&
ca
:
cliarg
s
)
{
for
(
auto
&
ca
:
x
s
)
{
// name field contains either only "--<long_name>" or
// "-<short name> [--<long name>]" depending on whether or not
// a ',' appears in the name
...
...
@@ -240,7 +241,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> cliargs) const {
std
::
ostringstream
oss
;
oss
<<
std
::
left
;
oss
<<
"Allowed options:"
<<
std
::
endl
;
for
(
auto
&
ca
:
cliarg
s
)
{
for
(
auto
&
ca
:
x
s
)
{
std
::
string
lhs
;
auto
separator
=
ca
.
name
.
find
(
','
);
if
(
separator
==
std
::
string
::
npos
)
{
...
...
libcaf_core/src/uniform_type_info_map.cpp
View file @
4a9ea16f
...
...
@@ -559,14 +559,16 @@ class default_meta_message : public uniform_type_info {
template
<
class
Iterator
>
struct
builtin_types_helper
{
Iterator
pos
;
builtin_types_helper
(
Iterator
first
)
:
pos
(
first
)
{}
builtin_types_helper
(
Iterator
first
)
:
pos
(
first
)
{
// nop
}
void
operator
()()
const
{
// end of recursion
}
template
<
class
T
,
class
...
Ts
>
void
operator
()(
T
&
arg
,
Ts
&
...
arg
s
)
{
*
pos
++
=
&
arg
;
(
*
this
)(
arg
s
...);
void
operator
()(
T
&
x
,
Ts
&
...
x
s
)
{
*
pos
++
=
&
x
;
(
*
this
)(
x
s
...);
}
};
...
...
libcaf_io/caf/io/middleman.hpp
View file @
4a9ea16f
...
...
@@ -109,9 +109,9 @@ class middleman : public detail::abstract_singleton {
* Adds a new hook to the middleman.
*/
template
<
class
C
,
typename
...
Ts
>
void
add_hook
(
Ts
&&
...
arg
s
)
{
void
add_hook
(
Ts
&&
...
x
s
)
{
// if only we could move a unique_ptr into a lambda in C++11
auto
ptr
=
new
C
(
std
::
forward
<
Ts
>
(
arg
s
)...);
auto
ptr
=
new
C
(
std
::
forward
<
Ts
>
(
x
s
)...);
backend
().
dispatch
([
=
]
{
ptr
->
next
.
swap
(
m_hooks
);
m_hooks
.
reset
(
ptr
);
...
...
libcaf_io/caf/io/spawn_io.hpp
View file @
4a9ea16f
...
...
@@ -48,11 +48,11 @@ actor spawn_io(F fun, Ts&&... xs) {
template
<
spawn_options
Os
=
no_spawn_options
,
typename
F
=
std
::
function
<
void
(
broker
*
)>,
class
...
Ts
>
actor
spawn_io_client
(
F
fun
,
const
std
::
string
&
host
,
uint16_t
port
,
Ts
&&
...
arg
s
)
{
uint16_t
port
,
Ts
&&
...
x
s
)
{
// provoke compiler error early
using
fun_res
=
decltype
(
fun
(
static_cast
<
broker
*>
(
nullptr
),
connection_handle
{},
std
::
forward
<
Ts
>
(
arg
s
)...));
std
::
forward
<
Ts
>
(
x
s
)...));
// prevent warning about unused local type
static_assert
(
std
::
is_same
<
fun_res
,
fun_res
>::
value
,
"your compiler is lying to you"
);
...
...
@@ -62,7 +62,7 @@ actor spawn_io_client(F fun, const std::string& host,
auto
mfptr
=
&
broker
::
functor_based
::
init
<
F
,
connection_handle
,
Ts
...
>
;
using
bi
=
std
::
function
<
void
(
broker
::
functor_based
*
,
F
,
connection_handle
)
>
;
using
namespace
std
::
placeholders
;
bi
init
=
std
::
bind
(
mfptr
,
_1
,
_2
,
_3
,
std
::
forward
<
Ts
>
(
arg
s
)...);
bi
init
=
std
::
bind
(
mfptr
,
_1
,
_2
,
_3
,
std
::
forward
<
Ts
>
(
x
s
)...);
return
spawn_class
<
broker
::
functor_based
>
(
nullptr
,
[
&
](
broker
::
functor_based
*
ptr
)
{
...
...
@@ -77,12 +77,12 @@ actor spawn_io_client(F fun, const std::string& host,
*/
template
<
spawn_options
Os
=
no_spawn_options
,
class
F
=
std
::
function
<
void
(
broker
*
)>,
class
...
Ts
>
actor
spawn_io_server
(
F
fun
,
uint16_t
port
,
Ts
&&
...
arg
s
)
{
actor
spawn_io_server
(
F
fun
,
uint16_t
port
,
Ts
&&
...
x
s
)
{
// same workaround as above
auto
mfptr
=
&
broker
::
functor_based
::
init
<
F
,
Ts
...
>
;
using
bi
=
std
::
function
<
void
(
broker
::
functor_based
*
,
F
)
>
;
using
namespace
std
::
placeholders
;
bi
init
=
std
::
bind
(
mfptr
,
_1
,
_2
,
std
::
forward
<
Ts
>
(
arg
s
)...);
bi
init
=
std
::
bind
(
mfptr
,
_1
,
_2
,
std
::
forward
<
Ts
>
(
x
s
)...);
return
spawn_class
<
broker
::
functor_based
>
(
nullptr
,
[
&
](
broker
::
functor_based
*
ptr
)
{
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
4a9ea16f
...
...
@@ -84,10 +84,10 @@ bool cc_valid_socket(caf::io::network::native_socket fd) {
// calls a C function and throws a `network_error` if `p` returns false
template
<
class
Predicate
,
class
F
,
class
...
Ts
>
auto
ccall
(
Predicate
p
,
const
char
*
errmsg
,
F
f
,
Ts
&&
...
arg
s
)
->
decltype
(
f
(
std
::
forward
<
Ts
>
(
arg
s
)...))
{
auto
ccall
(
Predicate
p
,
const
char
*
errmsg
,
F
f
,
Ts
&&
...
x
s
)
->
decltype
(
f
(
std
::
forward
<
Ts
>
(
x
s
)...))
{
using
namespace
caf
::
io
::
network
;
auto
result
=
f
(
std
::
forward
<
Ts
>
(
arg
s
)...);
auto
result
=
f
(
std
::
forward
<
Ts
>
(
x
s
)...);
if
(
!
p
(
result
))
{
std
::
ostringstream
oss
;
oss
<<
errmsg
<<
": "
<<
last_socket_error_as_string
()
...
...
unit_testing/test_atom.cpp
View file @
4a9ea16f
...
...
@@ -55,10 +55,12 @@ void foo() {
}
struct
send_to_self
{
send_to_self
(
blocking_actor
*
self
)
:
m_self
(
self
)
{}
send_to_self
(
blocking_actor
*
self
)
:
m_self
(
self
)
{
// nop
}
template
<
class
...
Ts
>
void
operator
()(
Ts
&&
...
arg
s
)
{
m_self
->
send
(
m_self
,
std
::
forward
<
Ts
>
(
arg
s
)...);
void
operator
()(
Ts
&&
...
x
s
)
{
m_self
->
send
(
m_self
,
std
::
forward
<
Ts
>
(
x
s
)...);
}
blocking_actor
*
m_self
;
};
...
...
unit_testing/test_match.cpp
View file @
4a9ea16f
...
...
@@ -50,11 +50,11 @@ void fill_mb(message_builder& mb, const T& x, const Ts&... xs) {
}
template
<
class
...
Ts
>
ptrdiff_t
invoked
(
message_handler
expr
,
const
Ts
&
...
arg
s
)
{
ptrdiff_t
invoked
(
message_handler
expr
,
const
Ts
&
...
x
s
)
{
vector
<
message
>
msgs
;
msgs
.
push_back
(
make_message
(
arg
s
...));
msgs
.
push_back
(
make_message
(
x
s
...));
message_builder
mb
;
fill_mb
(
mb
,
arg
s
...);
fill_mb
(
mb
,
x
s
...);
msgs
.
push_back
(
mb
.
to_message
());
set
<
ptrdiff_t
>
results
;
for
(
auto
&
msg
:
msgs
)
{
...
...
unit_testing/test_message.cpp
View file @
4a9ea16f
...
...
@@ -85,9 +85,9 @@ void test_extract3() {
}
void
test_extract_opts
()
{
auto
f
=
[](
std
::
vector
<
std
::
string
>
arg
s
)
{
auto
f
=
[](
std
::
vector
<
std
::
string
>
x
s
)
{
std
::
string
filename
;
auto
res
=
message_builder
(
args
.
begin
(),
arg
s
.
end
()).
extract_opts
({
auto
res
=
message_builder
(
xs
.
begin
(),
x
s
.
end
()).
extract_opts
({
{
"version,v"
,
"print version"
},
{
"file,f"
,
"set output file"
,
filename
},
{
"whatever"
,
"do whatever"
}
...
...
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