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
b1381c27
Commit
b1381c27
authored
May 30, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix several warnings
parent
c516ce0b
Changes
54
Hide whitespace changes
Inline
Side-by-side
Showing
54 changed files
with
386 additions
and
198 deletions
+386
-198
examples/broker/simple_broker.cpp
examples/broker/simple_broker.cpp
+5
-7
examples/broker/simple_http_broker.cpp
examples/broker/simple_http_broker.cpp
+4
-0
examples/custom_type/custom_types_1.cpp
examples/custom_type/custom_types_1.cpp
+6
-4
examples/custom_type/custom_types_2.cpp
examples/custom_type/custom_types_2.cpp
+4
-0
examples/custom_type/custom_types_3.cpp
examples/custom_type/custom_types_3.cpp
+7
-5
examples/message_passing/calculator.cpp
examples/message_passing/calculator.cpp
+5
-3
examples/message_passing/divider.cpp
examples/message_passing/divider.cpp
+6
-4
examples/message_passing/fixed_stack.cpp
examples/message_passing/fixed_stack.cpp
+5
-1
examples/remoting/distributed_calculator.cpp
examples/remoting/distributed_calculator.cpp
+3
-5
examples/remoting/group_chat.cpp
examples/remoting/group_chat.cpp
+4
-0
examples/remoting/group_server.cpp
examples/remoting/group_server.cpp
+4
-0
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+4
-1
libcaf_core/caf/actor.hpp
libcaf_core/caf/actor.hpp
+8
-3
libcaf_core/caf/actor_addr.hpp
libcaf_core/caf/actor_addr.hpp
+9
-3
libcaf_core/caf/actor_system_config.hpp
libcaf_core/caf/actor_system_config.hpp
+2
-0
libcaf_core/caf/config.hpp
libcaf_core/caf/config.hpp
+1
-0
libcaf_core/caf/data_processor.hpp
libcaf_core/caf/data_processor.hpp
+18
-18
libcaf_core/caf/deserializer.hpp
libcaf_core/caf/deserializer.hpp
+2
-0
libcaf_core/caf/detail/split_join.hpp
libcaf_core/caf/detail/split_join.hpp
+2
-2
libcaf_core/caf/execution_unit.hpp
libcaf_core/caf/execution_unit.hpp
+3
-0
libcaf_core/caf/function_view.hpp
libcaf_core/caf/function_view.hpp
+1
-1
libcaf_core/caf/input_range.hpp
libcaf_core/caf/input_range.hpp
+8
-0
libcaf_core/caf/is_typed_actor.hpp
libcaf_core/caf/is_typed_actor.hpp
+38
-0
libcaf_core/caf/mixin/sender.hpp
libcaf_core/caf/mixin/sender.hpp
+15
-1
libcaf_core/caf/policy/unprofiled.hpp
libcaf_core/caf/policy/unprofiled.hpp
+1
-15
libcaf_core/caf/policy/work_sharing.hpp
libcaf_core/caf/policy/work_sharing.hpp
+9
-0
libcaf_core/caf/policy/work_stealing.hpp
libcaf_core/caf/policy/work_stealing.hpp
+3
-15
libcaf_core/caf/scoped_actor.hpp
libcaf_core/caf/scoped_actor.hpp
+7
-2
libcaf_core/caf/stream_deserializer.hpp
libcaf_core/caf/stream_deserializer.hpp
+14
-9
libcaf_core/caf/stream_serializer.hpp
libcaf_core/caf/stream_serializer.hpp
+6
-2
libcaf_core/caf/streambuf.hpp
libcaf_core/caf/streambuf.hpp
+9
-6
libcaf_core/caf/type_erased_tuple.hpp
libcaf_core/caf/type_erased_tuple.hpp
+6
-1
libcaf_core/caf/typed_actor.hpp
libcaf_core/caf/typed_actor.hpp
+17
-7
libcaf_core/src/actor_addr.cpp
libcaf_core/src/actor_addr.cpp
+0
-12
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+1
-4
libcaf_core/src/config_option.cpp
libcaf_core/src/config_option.cpp
+2
-2
libcaf_core/src/deserializer.cpp
libcaf_core/src/deserializer.cpp
+4
-0
libcaf_core/src/local_actor.cpp
libcaf_core/src/local_actor.cpp
+4
-0
libcaf_core/src/node_id.cpp
libcaf_core/src/node_id.cpp
+1
-1
libcaf_core/src/parse_ini.cpp
libcaf_core/src/parse_ini.cpp
+3
-3
libcaf_core/src/scoped_actor.cpp
libcaf_core/src/scoped_actor.cpp
+4
-4
libcaf_core/src/unprofiled.cpp
libcaf_core/src/unprofiled.cpp
+30
-0
libcaf_core/src/work_sharing.cpp
libcaf_core/src/work_sharing.cpp
+30
-0
libcaf_core/src/work_stealing.cpp
libcaf_core/src/work_stealing.cpp
+30
-0
libcaf_core/test/extract.cpp
libcaf_core/test/extract.cpp
+6
-21
libcaf_core/test/request_response.cpp
libcaf_core/test/request_response.cpp
+6
-6
libcaf_core/test/splitter.cpp
libcaf_core/test/splitter.cpp
+7
-7
libcaf_core/test/streambuf.cpp
libcaf_core/test/streambuf.cpp
+8
-8
libcaf_io/caf/io/middleman.hpp
libcaf_io/caf/io/middleman.hpp
+2
-1
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+1
-0
libcaf_io/src/middleman_actor.cpp
libcaf_io/src/middleman_actor.cpp
+4
-4
libcaf_io/test/basp.cpp
libcaf_io/test/basp.cpp
+1
-1
libcaf_io/test/remote_actor.cpp
libcaf_io/test/remote_actor.cpp
+4
-7
tools/caf-run.cpp
tools/caf-run.cpp
+2
-2
No files found.
examples/broker/simple_broker.cpp
View file @
b1381c27
...
...
@@ -7,9 +7,7 @@
* - ./build/bin/broker -c localhost 4242 *
\ ******************************************************************************/
// This file is partially included in the manual, do not modify
// without updating the references in the *.tex files!
// Manual references: lines 46-50 (Actors.tex)
// Manual refs: 46-50 (Actors.tex)
#include "caf/config.hpp"
...
...
@@ -38,6 +36,8 @@ using std::endl;
using
namespace
caf
;
using
namespace
caf
::
io
;
namespace
{
using
ping_atom
=
atom_constant
<
atom
(
"ping"
)
>
;
using
pong_atom
=
atom_constant
<
atom
(
"pong"
)
>
;
using
kickoff_atom
=
atom_constant
<
atom
(
"kickoff"
)
>
;
...
...
@@ -175,10 +175,6 @@ behavior server(broker* self, const actor& buddy) {
};
}
optional
<
uint16_t
>
as_u16
(
const
std
::
string
&
str
)
{
return
static_cast
<
uint16_t
>
(
stoul
(
str
));
}
class
config
:
public
actor_system_config
{
public:
uint16_t
port
=
0
;
...
...
@@ -211,4 +207,6 @@ void caf_main(actor_system& system, const config& cfg) {
send_as
(
io_actor
,
ping_actor
,
kickoff_atom
::
value
,
io_actor
);
}
}
// namespace <anonymous>
CAF_MAIN
(
io
::
middleman
)
examples/broker/simple_http_broker.cpp
View file @
b1381c27
...
...
@@ -11,6 +11,8 @@ using std::endl;
using
namespace
caf
;
using
namespace
caf
::
io
;
namespace
{
using
tick_atom
=
atom_constant
<
atom
(
"tick"
)
>
;
constexpr
const
char
http_ok
[]
=
R"__(HTTP/1.1 200 OK
...
...
@@ -85,4 +87,6 @@ void caf_main(actor_system& system, const config& cfg) {
anon_send_exit
(
server_actor
,
exit_reason
::
user_shutdown
);
}
}
// namespace <anonymous>
CAF_MAIN
(
io
::
middleman
)
examples/custom_type/custom_types_1.cpp
View file @
b1381c27
// Showcases how to add custom POD message types.
// This file is referenced in the manual, do not modify without updating refs!
// ConfiguringActorApplications: 23-26, 29-33, 87-90, 93-96
// Manual refs: 23-26, 29-33, 87-90, 93-96 (ConfiguringActorApplications)
#include <tuple>
#include <string>
#include <vector>
#include <cassert>
...
...
@@ -19,6 +17,8 @@ using std::vector;
using
namespace
caf
;
namespace
{
// POD struct foo
struct
foo
{
std
::
vector
<
int
>
a
;
...
...
@@ -112,7 +112,7 @@ void caf_main(actor_system& system, const config&) {
// must be equal
assert
(
to_string
(
f1
)
==
to_string
(
f2
));
// spawn a testee that receives two messages of user-defined type
auto
t
=
system
.
spawn
(
testee
,
2
);
auto
t
=
system
.
spawn
(
testee
,
2
u
);
scoped_actor
self
{
system
};
// send t a foo
self
->
send
(
t
,
foo
{
std
::
vector
<
int
>
{
1
,
2
,
3
,
4
},
5
});
...
...
@@ -121,4 +121,6 @@ void caf_main(actor_system& system, const config&) {
self
->
await_all_other_actors_done
();
}
}
// namespace <anonymous>
CAF_MAIN
()
examples/custom_type/custom_types_2.cpp
View file @
b1381c27
...
...
@@ -12,6 +12,8 @@ using std::make_pair;
using
namespace
caf
;
namespace
{
// a simple class using getter and setter member functions
class
foo
{
public:
...
...
@@ -72,4 +74,6 @@ void caf_main(actor_system& system, const config&) {
anon_send
(
system
.
spawn
(
testee
),
foo
{
1
,
2
});
}
}
// namespace <anonymous>
CAF_MAIN
()
examples/custom_type/custom_types_3.cpp
View file @
b1381c27
// Showcases how to add custom message types to CAF
// if no friend access for serialization is possible.
// This file is referenced in the manual, do not modify without updating refs!
// ConfiguringActorApplications: 57-59, 64-66
// Showcases custom message types that cannot provide
// friend access to the serialize() function.
// Manual refs: 57-59, 64-66 (ConfiguringActorApplications)
#include <utility>
#include <iostream>
...
...
@@ -16,6 +14,8 @@ using std::make_pair;
using
namespace
caf
;
namespace
{
// identical to our second custom type example,
// but without friend declarations
class
foo
{
...
...
@@ -90,4 +90,6 @@ void caf_main(actor_system& system, const config&) {
anon_send
(
system
.
spawn
(
testee
),
foo
{
1
,
2
});
}
}
// namespace <anonymous>
CAF_MAIN
()
examples/message_passing/calculator.cpp
View file @
b1381c27
...
...
@@ -3,9 +3,7 @@
* for both the blocking and the event-based API. *
\******************************************************************************/
// This file is partially included in the manual, do not modify
// without updating the references in the *.tex files!
// Manual references: lines 17-21, 31-65, 67-101, and 134-139 (Actor.tex)
// Manual refs: lines 19-21, 31-65, 67-101, 134-139 (Actor)
#include <iostream>
...
...
@@ -14,6 +12,8 @@
using
std
::
endl
;
using
namespace
caf
;
namespace
{
using
add_atom
=
atom_constant
<
atom
(
"add"
)
>
;
using
sub_atom
=
atom_constant
<
atom
(
"sub"
)
>
;
...
...
@@ -138,4 +138,6 @@ void caf_main(actor_system& system) {
tester
(
self
,
a1
,
1
,
2
,
a2
,
3
,
4
,
a3
,
5
,
6
,
a4
,
7
,
8
,
a5
,
9
,
10
,
a6
,
11
,
12
);
}
}
// namespace <anonymous>
CAF_MAIN
()
examples/message_passing/divider.cpp
View file @
b1381c27
...
...
@@ -2,10 +2,8 @@
* A very basic, interactive divider. *
\******************************************************************************/
// This file is partially included in the manual, do not modify
// without updating the references in the *.tex files!
// Manual references: lines 19-25, 35-48, and 63-73 (MessagePassing.tex);
// lines 19-34, and 51-56 (Error.tex)
// Manual refs: 19-25, 35-48, 63-73 (MessagePassing);
// 19-34, 51-56 (Error)
#include <iostream>
...
...
@@ -16,6 +14,8 @@ using std::endl;
using
std
::
flush
;
using
namespace
caf
;
namespace
{
enum
class
math_error
:
uint8_t
{
division_by_zero
=
1
};
...
...
@@ -77,4 +77,6 @@ void caf_main(actor_system& system, const config&) {
);
}
}
// namespace <anonymous>
CAF_MAIN
()
examples/message_passing/fixed_stack.cpp
View file @
b1381c27
...
...
@@ -5,6 +5,8 @@
using
std
::
endl
;
using
namespace
caf
;
namespace
{
using
pop_atom
=
atom_constant
<
atom
(
"pop"
)
>
;
using
push_atom
=
atom_constant
<
atom
(
"push"
)
>
;
...
...
@@ -71,7 +73,7 @@ private:
void
caf_main
(
actor_system
&
system
)
{
scoped_actor
self
{
system
};
auto
st
=
self
->
spawn
<
fixed_stack
>
(
5
);
auto
st
=
self
->
spawn
<
fixed_stack
>
(
5
u
);
// fill stack
for
(
int
i
=
0
;
i
<
10
;
++
i
)
self
->
send
(
st
,
push_atom
::
value
,
i
);
...
...
@@ -92,4 +94,6 @@ void caf_main(actor_system& system) {
self
->
send_exit
(
st
,
exit_reason
::
user_shutdown
);
}
}
// namespace <anonymous>
CAF_MAIN
()
examples/remoting/distributed_calculator.cpp
View file @
b1381c27
...
...
@@ -9,9 +9,7 @@
// Run client at the same host:
// - ./build/bin/distributed_math_actor -c -p 4242
// This file is partially included in the manual, do not modify
// without updating the references in the *.tex files!
// Manual references: lines 254-266 (ConfiguringActorSystems.tex)
// Manual refs: 250-262 (ConfiguringActorSystems)
#include <array>
#include <vector>
...
...
@@ -249,8 +247,6 @@ void client_repl(actor_system& system, string host, uint16_t port) {
}
}
}
// namespace <anonymous>
class
config
:
public
actor_system_config
{
public:
uint16_t
port
=
0
;
...
...
@@ -286,4 +282,6 @@ void caf_main(actor_system& system, const config& cfg) {
client_repl
(
system
,
cfg
.
host
,
cfg
.
port
);
}
}
// namespace <anonymous>
CAF_MAIN
(
io
::
middleman
)
examples/remoting/group_chat.cpp
View file @
b1381c27
...
...
@@ -23,6 +23,8 @@
using
namespace
std
;
using
namespace
caf
;
namespace
{
using
broadcast_atom
=
atom_constant
<
atom
(
"broadcast"
)
>
;
struct
line
{
string
str
;
};
...
...
@@ -153,4 +155,6 @@ void caf_main(actor_system& system, const config& cfg) {
anon_send_exit
(
client_actor
,
exit_reason
::
user_shutdown
);
}
}
// namespace <anonymous>
CAF_MAIN
(
io
::
middleman
)
examples/remoting/group_server.cpp
View file @
b1381c27
...
...
@@ -18,6 +18,8 @@
using
namespace
std
;
using
namespace
caf
;
namespace
{
class
config
:
public
actor_system_config
{
public:
uint16_t
port
=
0
;
...
...
@@ -39,4 +41,6 @@ void caf_main(actor_system& system, const config& cfg) {
cerr
<<
"illegal command"
<<
endl
;
}
}
// namespace <anonymous>
CAF_MAIN
(
io
::
middleman
)
libcaf_core/CMakeLists.txt
View file @
b1381c27
...
...
@@ -88,7 +88,10 @@ set (LIBCAF_CORE_SRCS
src/try_match.cpp
src/type_erased_value.cpp
src/type_erased_tuple.cpp
src/uniform_type_info_map.cpp
)
src/uniform_type_info_map.cpp
src/unprofiled.cpp
src/work_stealing.cpp
src/work_sharing.cpp
)
add_custom_target
(
libcaf_core
)
...
...
libcaf_core/caf/actor.hpp
View file @
b1381c27
...
...
@@ -117,14 +117,19 @@ public:
/// Returns the address of the stored actor.
actor_addr
address
()
const
noexcept
;
/// Returns the ID of this actor.
inline
actor_id
id
()
const
noexcept
{
return
ptr_
->
id
();
}
/// Returns the origin node of this actor.
inline
node_id
node
()
const
noexcept
{
return
ptr_
->
node
();
}
/// Returns the
ID of this actor
.
inline
actor_
id
id
()
const
noexcept
{
return
ptr_
->
id
()
;
/// Returns the
hosting actor system
.
inline
actor_
system
&
home_system
()
const
noexcept
{
return
*
ptr_
->
home_system
;
}
/// Exchange content of `*this` and `other`.
...
...
libcaf_core/caf/actor_addr.hpp
View file @
b1381c27
...
...
@@ -73,13 +73,19 @@ public:
actor_addr
(
const
unsafe_actor_handle_init_t
&
);
/// Returns the ID of this actor.
actor_id
id
()
const
noexcept
;
inline
actor_id
id
()
const
noexcept
{
return
ptr_
->
id
();
}
/// Returns the origin node of this actor.
node_id
node
()
const
noexcept
;
inline
node_id
node
()
const
noexcept
{
return
ptr_
->
node
();
}
/// Returns the hosting actor system.
actor_system
*
home_system
()
const
noexcept
;
inline
actor_system
&
home_system
()
const
noexcept
{
return
*
ptr_
->
home_system
;
}
/// Exchange content of `*this` and `other`.
void
swap
(
actor_addr
&
other
)
noexcept
;
...
...
libcaf_core/caf/actor_system_config.hpp
View file @
b1381c27
...
...
@@ -32,6 +32,7 @@
#include "caf/config_value.hpp"
#include "caf/config_option.hpp"
#include "caf/actor_factory.hpp"
#include "caf/is_typed_actor.hpp"
#include "caf/type_erased_value.hpp"
#include "caf/detail/safe_equal.hpp"
...
...
@@ -116,6 +117,7 @@ public:
template
<
class
T
>
actor_system_config
&
add_message_type
(
std
::
string
name
)
{
static_assert
(
std
::
is_empty
<
T
>::
value
||
is_typed_actor
<
T
>::
value
||
(
std
::
is_default_constructible
<
T
>::
value
&&
std
::
is_copy_constructible
<
T
>::
value
),
"T must provide default and copy constructors"
);
...
...
libcaf_core/caf/config.hpp
View file @
b1381c27
...
...
@@ -97,6 +97,7 @@
_Pragma("clang diagnostic ignored \"-Wdisabled-macro-expansion\"") \
_Pragma("clang diagnostic ignored \"-Wunreachable-code\"") \
_Pragma("clang diagnostic ignored \"-Wreserved-id-macro\"") \
_Pragma("clang diagnostic ignored \"-Wdouble-promotion\"") \
_Pragma("clang diagnostic ignored \"-Wsign-conversion\"")
# define CAF_PUSH_NON_VIRTUAL_DTOR_WARNING \
_Pragma("clang diagnostic push") \
...
...
libcaf_core/caf/data_processor.hpp
View file @
b1381c27
...
...
@@ -151,11 +151,11 @@ public:
apply
(
T
&
x
)
{
using
underlying
=
typename
std
::
underlying_type
<
T
>::
type
;
struct
{
void
operator
()(
T
&
x
,
underlying
&
y
)
const
{
x
=
static_cast
<
T
>
(
y
);
void
operator
()(
T
&
lhs
,
underlying
&
rhs
)
const
{
lhs
=
static_cast
<
T
>
(
rhs
);
}
void
operator
()(
underlying
&
x
,
T
&
y
)
const
{
x
=
static_cast
<
underlying
>
(
y
);
void
operator
()(
underlying
&
lhs
,
T
&
rhs
)
const
{
lhs
=
static_cast
<
underlying
>
(
rhs
);
}
}
assign
;
underlying
tmp
;
...
...
@@ -171,11 +171,11 @@ public:
void
apply
(
bool
&
x
)
{
struct
{
void
operator
()(
bool
&
x
,
uint8_t
&
y
)
const
{
x
=
y
!=
0
;
void
operator
()(
bool
&
lhs
,
uint8_t
&
rhs
)
const
{
lhs
=
rhs
!=
0
;
}
void
operator
()(
uint8_t
&
x
,
bool
&
y
)
const
{
x
=
y
?
1
:
0
;
void
operator
()(
uint8_t
&
lhs
,
bool
&
rhs
)
const
{
lhs
=
rhs
?
1
:
0
;
}
}
assign
;
uint8_t
tmp
;
...
...
@@ -324,12 +324,12 @@ public:
// always save/store durations as int64_t to work around possibly
// different integer types on different plattforms for standard typedefs
struct
{
void
operator
()(
duration_type
&
x
,
int64_t
&
y
)
const
{
duration_type
tmp
{
y
};
x
=
tmp
;
void
operator
()(
duration_type
&
lhs
,
int64_t
&
rhs
)
const
{
duration_type
tmp
{
rhs
};
lhs
=
tmp
;
}
void
operator
()(
int64_t
&
x
,
duration_type
&
y
)
const
{
x
=
y
.
count
();
void
operator
()(
int64_t
&
lhs
,
duration_type
&
rhs
)
const
{
lhs
=
rhs
.
count
();
}
}
assign
;
int64_t
tmp
;
...
...
@@ -345,12 +345,12 @@ public:
// always save/store floating point durations
// as doubles for the same reason as above
struct
{
void
operator
()(
duration_type
&
x
,
double
&
y
)
const
{
duration_type
tmp
{
y
};
x
=
tmp
;
void
operator
()(
duration_type
&
lhs
,
double
&
rhs
)
const
{
duration_type
tmp
{
rhs
};
lhs
=
tmp
;
}
void
operator
()(
double
&
x
,
duration_type
&
y
)
const
{
x
=
y
.
count
();
void
operator
()(
double
&
lhs
,
duration_type
&
rhs
)
const
{
lhs
=
rhs
.
count
();
}
}
assign
;
double
tmp
;
...
...
libcaf_core/caf/deserializer.hpp
View file @
b1381c27
...
...
@@ -34,6 +34,8 @@ namespace caf {
/// Technology-independent deserialization interface.
class
deserializer
:
public
data_processor
<
deserializer
>
{
public:
~
deserializer
();
using
super
=
data_processor
<
deserializer
>
;
using
is_saving
=
std
::
false_type
;
...
...
libcaf_core/caf/detail/split_join.hpp
View file @
b1381c27
...
...
@@ -49,8 +49,8 @@ public:
}
behavior
make_behavior
()
override
{
auto
f
=
[
=
](
local_actor
*
,
const
type_erased_tuple
*
x
)
->
result
<
message
>
{
auto
msg
=
message
::
from
(
x
);
auto
f
=
[
=
](
local_actor
*
,
const
type_erased_tuple
*
tup
)
->
result
<
message
>
{
auto
msg
=
message
::
from
(
tup
);
auto
rp
=
this
->
make_response_promise
();
split_
(
workset_
,
msg
);
for
(
auto
&
x
:
workset_
)
...
...
libcaf_core/caf/execution_unit.hpp
View file @
b1381c27
...
...
@@ -32,6 +32,9 @@ class execution_unit {
public:
explicit
execution_unit
(
actor_system
*
sys
);
execution_unit
(
execution_unit
&&
)
=
delete
;
execution_unit
(
const
execution_unit
&
)
=
delete
;
virtual
~
execution_unit
();
/// Enqueues `ptr` to the job list of the execution unit.
...
...
libcaf_core/caf/function_view.hpp
View file @
b1381c27
...
...
@@ -108,7 +108,7 @@ public:
function_view
(
function_view
&&
x
)
:
impl_
(
std
::
move
(
x
.
impl_
))
{
if
(
!
impl_
.
unsafe
())
{
new
(
&
self_
)
scoped_actor
(
std
::
move
(
x
.
self_
));
new
(
&
self_
)
scoped_actor
(
impl_
.
home_system
());
//(
std::move(x.self_));
x
.
self_
.
~
scoped_actor
();
}
}
...
...
libcaf_core/caf/input_range.hpp
View file @
b1381c27
...
...
@@ -29,6 +29,14 @@ namespace caf {
template
<
class
T
>
class
input_range
{
public:
virtual
~
input_range
()
{
// nop
}
input_range
()
=
default
;
input_range
(
const
input_range
&
)
=
default
;
input_range
&
operator
=
(
const
input_range
&
)
=
default
;
class
iterator
:
public
std
::
iterator
<
std
::
input_iterator_tag
,
T
>
{
public:
iterator
(
input_range
*
range
)
:
xs_
(
range
)
{
...
...
libcaf_core/caf/is_typed_actor.hpp
0 → 100644
View file @
b1381c27
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| 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_IS_TYPED_ACTOR_HPP
#define CAF_IS_TYPED_ACTOR_HPP
#include "caf/fwd.hpp"
namespace
caf
{
/**
* Evaluates to true if `T` is a `typed_actor<...>`.
*/
template
<
class
T
>
struct
is_typed_actor
:
std
::
false_type
{
};
template
<
class
...
Ts
>
struct
is_typed_actor
<
typed_actor
<
Ts
...
>>
:
std
::
true_type
{
};
}
// namespace caf
#endif //CAF_IS_TYPED_ACTOR_HPP
libcaf_core/caf/mixin/sender.hpp
View file @
b1381c27
...
...
@@ -44,7 +44,6 @@ public:
}
/// Sends `{xs...}` as a synchronous message to `dest` with priority `mp`.
/// @returns A handle identifying a future-like handle to the response.
/// @warning The returned handle is actor specific and the response to the
/// sent message cannot be received by another actor.
/// @throws std::invalid_argument if `dest == invalid_actor`
...
...
@@ -74,6 +73,21 @@ public:
this
->
context
(),
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
message_priority
P
=
message_priority
::
normal
,
class
Source
=
actor
,
class
Dest
=
actor
,
class
...
Ts
>
void
anon_send
(
const
Dest
&
dest
,
Ts
&&
...
xs
)
{
static_assert
(
sizeof
...(
Ts
)
>
0
,
"no message to send"
);
using
token
=
detail
::
type_list
<
typename
detail
::
implicit_conversions
<
typename
std
::
decay
<
Ts
>::
type
>::
type
...
>
;
static_assert
(
actor_accepts_message
(
signatures_of
<
Dest
>
(),
token
{}),
"receiver does not accept given message"
);
dest
->
eq_impl
(
message_id
::
make
(
P
),
nullptr
,
this
->
context
(),
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
message_priority
P
=
message_priority
::
normal
,
class
Dest
=
actor
,
class
...
Ts
>
void
delayed_send
(
const
Dest
&
dest
,
const
duration
&
rtime
,
Ts
&&
...
xs
)
{
...
...
libcaf_core/caf/policy/unprofiled.hpp
View file @
b1381c27
...
...
@@ -32,21 +32,7 @@ namespace policy {
/// factor common utilities for implementing actual policies.
class
unprofiled
{
public:
virtual
~
unprofiled
()
=
default
;
/// Policy-specific data fields for the coordinator.
struct
coordinator_data
{
inline
explicit
coordinator_data
(
scheduler
::
abstract_coordinator
*
)
{
// nop
}
};
/// Policy-specific data fields for the worker.
struct
worker_data
{
inline
explicit
worker_data
(
scheduler
::
abstract_coordinator
*
)
{
// nop
}
};
virtual
~
unprofiled
();
/// Performs cleanup action before a shutdown takes place.
template
<
class
Worker
>
...
...
libcaf_core/caf/policy/work_sharing.hpp
View file @
b1381c27
...
...
@@ -31,12 +31,15 @@
namespace
caf
{
namespace
policy
{
/// Implements scheduling of actors via work sharing (central job queue).
/// @extends scheduler_policy
class
work_sharing
:
public
unprofiled
{
public:
// A thread-safe queue implementation.
using
queue_type
=
std
::
list
<
resumable
*>
;
~
work_sharing
();
struct
coordinator_data
{
inline
explicit
coordinator_data
(
scheduler
::
abstract_coordinator
*
)
{
// nop
...
...
@@ -47,6 +50,12 @@ public:
std
::
condition_variable
cv
;
};
struct
worker_data
{
inline
explicit
worker_data
(
scheduler
::
abstract_coordinator
*
)
{
// nop
}
};
template
<
class
Coordinator
>
void
enqueue
(
Coordinator
*
self
,
resumable
*
job
)
{
queue_type
l
;
...
...
libcaf_core/caf/policy/work_stealing.hpp
View file @
b1381c27
...
...
@@ -34,24 +34,12 @@
namespace
caf
{
namespace
policy
{
/// Implements scheduling of actors via work stealing. This implementation uses
/// two queues: a synchronized queue accessible by other threads and an internal
/// queue. Access to the synchronized queue is minimized.
/// The reasoning behind this design decision is that it
/// has been shown that stealing actually is very rare for most workloads [1].
/// Hence, implementations should focus on the performance in
/// the non-stealing case. For this reason, each worker has an exposed
/// job queue that can be accessed by the central scheduler instance as
/// well as other workers, but it also has a private job list it is
/// currently working on. To account for the load balancing aspect, each
/// worker makes sure that at least one job is left in its exposed queue
/// to allow other workers to steal it.
///
/// [1] http://dl.acm.org/citation.cfm?doid=2398857.2384639
///
/// Implements scheduling of actors via work stealing.
/// @extends scheduler_policy
class
work_stealing
:
public
unprofiled
{
public:
~
work_stealing
();
// A thread-safe queue implementation.
using
queue_type
=
detail
::
double_ended_queue
<
resumable
>
;
...
...
libcaf_core/caf/scoped_actor.hpp
View file @
b1381c27
...
...
@@ -45,15 +45,20 @@ public:
// tell actor_cast this is a non-null handle type
static
constexpr
bool
has_non_null_guarantee
=
true
;
scoped_actor
(
const
scoped_actor
&
)
=
delete
;
scoped_actor
(
actor_system
&
sys
,
bool
hide_actor
=
false
);
scoped_actor
(
const
scoped_actor
&
)
=
delete
;
scoped_actor
&
operator
=
(
const
scoped_actor
&
)
=
delete
;
scoped_actor
(
scoped_actor
&&
)
=
default
;
scoped_actor
&
operator
=
(
scoped_actor
&&
)
=
default
;
~
scoped_actor
();
inline
actor_system
&
home_system
()
const
{
return
*
self_
->
home_system
;
}
inline
blocking_actor
*
operator
->
()
const
{
return
ptr
();
}
...
...
libcaf_core/caf/stream_deserializer.hpp
View file @
b1381c27
...
...
@@ -94,8 +94,10 @@ public:
}
void
apply_raw
(
size_t
num_bytes
,
void
*
data
)
override
{
auto
n
=
streambuf_
.
sgetn
(
reinterpret_cast
<
char_type
*>
(
data
),
num_bytes
);
range_check
(
n
,
num_bytes
);
auto
n
=
streambuf_
.
sgetn
(
reinterpret_cast
<
char_type
*>
(
data
),
static_cast
<
std
::
streamsize
>
(
num_bytes
));
CAF_ASSERT
(
n
>=
0
);
range_check
(
static_cast
<
size_t
>
(
n
),
num_bytes
);
}
protected:
...
...
@@ -112,7 +114,7 @@ protected:
if
(
traits
::
eq_int_type
(
c
,
traits
::
eof
()))
throw
std
::
out_of_range
{
"stream_deserializer<T>::begin_sequence"
};
low7
=
static_cast
<
uint8_t
>
(
traits
::
to_char_type
(
c
));
x
|=
(
low7
&
0x7F
)
<<
(
7
*
n
);
x
|=
static_cast
<
T
>
((
low7
&
0x7F
)
<<
(
7
*
n
)
);
++
n
;
}
while
(
low7
&
0x80
);
return
n
;
...
...
@@ -160,8 +162,9 @@ protected:
// TODO: When using C++14, switch to str.data(), which then has a
// non-const overload.
auto
data
=
reinterpret_cast
<
char_type
*>
(
&
str
[
0
]);
size_t
n
=
streambuf_
.
sgetn
(
data
,
str_size
);
range_check
(
n
,
str_size
);
auto
n
=
streambuf_
.
sgetn
(
data
,
static_cast
<
std
::
streamsize
>
(
str_size
));
CAF_ASSERT
(
n
>=
0
);
range_check
(
static_cast
<
size_t
>
(
n
),
str_size
);
end_sequence
();
break
;
}
...
...
@@ -174,8 +177,9 @@ protected:
// TODO: When using C++14, switch to str.data(), which then has a
// non-const overload.
auto
data
=
reinterpret_cast
<
char_type
*>
(
&
str
[
0
]);
size_t
n
=
streambuf_
.
sgetn
(
data
,
bytes
);
range_check
(
n
,
bytes
);
auto
n
=
streambuf_
.
sgetn
(
data
,
static_cast
<
std
::
streamsize
>
(
bytes
));
CAF_ASSERT
(
n
>=
0
);
range_check
(
static_cast
<
size_t
>
(
n
),
str_size
);
end_sequence
();
break
;
}
...
...
@@ -188,8 +192,9 @@ protected:
// TODO: When using C++14, switch to str.data(), which then has a
// non-const overload.
auto
data
=
reinterpret_cast
<
char_type
*>
(
&
str
[
0
]);
size_t
n
=
streambuf_
.
sgetn
(
data
,
bytes
);
range_check
(
n
,
bytes
);
auto
n
=
streambuf_
.
sgetn
(
data
,
static_cast
<
std
::
streamsize
>
(
bytes
));
CAF_ASSERT
(
n
>=
0
);
range_check
(
static_cast
<
size_t
>
(
n
),
str_size
);
end_sequence
();
break
;
}
...
...
libcaf_core/caf/stream_serializer.hpp
View file @
b1381c27
...
...
@@ -92,7 +92,8 @@ public:
}
void
apply_raw
(
size_t
num_bytes
,
void
*
data
)
override
{
streambuf_
.
sputn
(
reinterpret_cast
<
char_type
*>
(
data
),
num_bytes
);
streambuf_
.
sputn
(
reinterpret_cast
<
char_type
*>
(
data
),
static_cast
<
std
::
streamsize
>
(
num_bytes
));
}
protected:
...
...
@@ -109,7 +110,10 @@ protected:
x
>>=
7
;
}
*
i
++
=
static_cast
<
uint8_t
>
(
x
)
&
0x7f
;
return
streambuf_
.
sputn
(
reinterpret_cast
<
char_type
*>
(
buf
),
i
-
buf
);
auto
res
=
streambuf_
.
sputn
(
reinterpret_cast
<
char_type
*>
(
buf
),
static_cast
<
std
::
streamsize
>
(
i
-
buf
));
CAF_ASSERT
(
res
>=
0
);
return
static_cast
<
size_t
>
(
res
);
}
void
apply_builtin
(
builtin
type
,
void
*
val
)
override
{
...
...
libcaf_core/caf/streambuf.hpp
View file @
b1381c27
...
...
@@ -99,16 +99,18 @@ protected:
std
::
streamsize
xsputn
(
const
char_type
*
s
,
std
::
streamsize
n
)
override
{
auto
available
=
this
->
epptr
()
-
this
->
pptr
();
auto
actual
=
std
::
min
(
n
,
available
);
std
::
memcpy
(
this
->
pptr
(),
s
,
actual
*
sizeof
(
char_type
));
this
->
pbump
(
actual
);
std
::
memcpy
(
this
->
pptr
(),
s
,
static_cast
<
size_t
>
(
actual
)
*
sizeof
(
char_type
));
this
->
pbump
(
static_cast
<
int
>
(
actual
));
return
actual
;
}
std
::
streamsize
xsgetn
(
char_type
*
s
,
std
::
streamsize
n
)
override
{
auto
available
=
this
->
egptr
()
-
this
->
gptr
();
auto
actual
=
std
::
min
(
n
,
available
);
std
::
memcpy
(
s
,
this
->
gptr
(),
actual
*
sizeof
(
char_type
));
this
->
gbump
(
actual
);
std
::
memcpy
(
s
,
this
->
gptr
(),
static_cast
<
size_t
>
(
actual
)
*
sizeof
(
char_type
));
this
->
gbump
(
static_cast
<
int
>
(
actual
));
return
actual
;
}
};
...
...
@@ -180,8 +182,9 @@ protected:
std
::
streamsize
xsgetn
(
char_type
*
s
,
std
::
streamsize
n
)
override
{
auto
available
=
this
->
egptr
()
-
this
->
gptr
();
auto
actual
=
std
::
min
(
n
,
available
);
std
::
memcpy
(
s
,
this
->
gptr
(),
actual
*
sizeof
(
char_type
));
this
->
gbump
(
actual
);
std
::
memcpy
(
s
,
this
->
gptr
(),
static_cast
<
size_t
>
(
actual
)
*
sizeof
(
char_type
));
this
->
gbump
(
static_cast
<
int
>
(
actual
));
return
actual
;
}
...
...
libcaf_core/caf/type_erased_tuple.hpp
View file @
b1381c27
...
...
@@ -40,6 +40,9 @@ public:
// -- constructors, destructors, and assignment operators --------------------
type_erased_tuple
()
=
default
;
type_erased_tuple
(
const
type_erased_tuple
&
)
=
default
;
virtual
~
type_erased_tuple
();
// -- pure virtual modifiers -------------------------------------------------
...
...
@@ -141,7 +144,9 @@ public:
init
();
}
type_erased_tuple_view
(
const
type_erased_tuple_view
&
other
)
:
xs_
(
other
.
xs_
)
{
type_erased_tuple_view
(
const
type_erased_tuple_view
&
other
)
:
type_erased_tuple
(),
xs_
(
other
.
xs_
)
{
init
();
}
...
...
libcaf_core/caf/typed_actor.hpp
View file @
b1381c27
...
...
@@ -62,10 +62,15 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
public:
static_assert
(
sizeof
...(
Sigs
)
>
0
,
"Empty typed actor handle"
);
//
grant access to private ctor
//
-- friend types that need access to private ctors
friend
class
local_actor
;
// friend with all possible instantiations
template
<
class
>
friend
class
data_processor
;
template
<
class
>
friend
class
type_erased_value_impl
;
template
<
class
...
>
friend
class
typed_actor
;
...
...
@@ -126,8 +131,6 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
using
stateful_broker_pointer
=
stateful_actor
<
State
,
broker_base
>*
;
typed_actor
()
=
delete
;
typed_actor
(
typed_actor
&&
)
=
default
;
typed_actor
(
const
typed_actor
&
)
=
default
;
typed_actor
&
operator
=
(
typed_actor
&&
)
=
default
;
...
...
@@ -184,14 +187,19 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
return
{
ptr_
.
get
(),
true
};
}
/// Returns the ID of this actor.
actor_id
id
()
const
noexcept
{
return
ptr_
->
id
();
}
/// Returns the origin node of this actor.
node_id
node
()
const
noexcept
{
return
ptr_
->
node
();
}
/// Returns the
ID of this actor
.
actor_id
id
()
const
noexcept
{
return
ptr_
->
id
()
;
/// Returns the
hosting actor system
.
inline
actor_system
&
home_system
()
const
noexcept
{
return
*
ptr_
->
home_system
;
}
/// Exchange content of `*this` and `other`.
...
...
@@ -262,6 +270,8 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
/// @endcond
private:
typed_actor
()
=
default
;
actor_control_block
*
get
()
const
noexcept
{
return
ptr_
.
get
();
}
...
...
libcaf_core/src/actor_addr.cpp
View file @
b1381c27
...
...
@@ -71,18 +71,6 @@ intptr_t actor_addr::compare(const actor_control_block* other) const noexcept {
return
compare
(
ptr_
.
get
(),
other
);
}
actor_id
actor_addr
::
id
()
const
noexcept
{
return
(
ptr_
)
?
ptr_
->
id
()
:
0
;
}
node_id
actor_addr
::
node
()
const
noexcept
{
return
ptr_
?
ptr_
->
node
()
:
node_id
{};
}
actor_system
*
actor_addr
::
home_system
()
const
noexcept
{
return
ptr_
?
ptr_
->
home_system
:
nullptr
;
}
void
actor_addr
::
swap
(
actor_addr
&
other
)
noexcept
{
ptr_
.
swap
(
other
.
ptr_
);
}
...
...
libcaf_core/src/actor_system_config.cpp
View file @
b1381c27
...
...
@@ -48,10 +48,7 @@ public:
key
+=
'.'
;
// name can have format "<long>,<short>"; consider only long name
auto
name_begin
=
x
->
name
();
auto
name_end
=
name_begin
;
for
(
auto
c
=
*
name_end
;
c
!=
','
&&
c
!=
0
;
++
name_end
)
{
// nop
}
const
char
*
name_end
=
strchr
(
x
->
name
(),
','
);
key
.
insert
(
key
.
end
(),
name_begin
,
name_end
);
//key += x->name();
sinks_
.
emplace
(
std
::
move
(
key
),
x
->
to_sink
());
...
...
libcaf_core/src/config_option.cpp
View file @
b1381c27
...
...
@@ -69,14 +69,14 @@ const char* config_option::type_name_visitor::operator()(atom_value) const {
bool
config_option
::
assign_config_value
(
size_t
&
x
,
int64_t
&
y
)
{
if
(
y
<
0
||
!
unsigned_assign_in_range
(
x
,
y
))
return
false
;
x
=
st
d
::
move
(
y
);
x
=
st
atic_cast
<
size_t
>
(
y
);
return
true
;
}
bool
config_option
::
assign_config_value
(
uint16_t
&
x
,
int64_t
&
y
)
{
if
(
y
<
0
||
y
>
std
::
numeric_limits
<
uint16_t
>::
max
())
return
false
;
x
=
st
d
::
move
(
y
);
x
=
st
atic_cast
<
uint16_t
>
(
y
);
return
true
;
}
...
...
libcaf_core/src/deserializer.cpp
View file @
b1381c27
...
...
@@ -23,6 +23,10 @@
namespace
caf
{
deserializer
::~
deserializer
()
{
// nop
}
deserializer
::
deserializer
(
actor_system
&
x
)
:
super
(
x
.
dummy_execution_unit
())
{
// nop
}
...
...
libcaf_core/src/local_actor.cpp
View file @
b1381c27
...
...
@@ -361,6 +361,8 @@ local_actor::msg_type local_actor::filter_msg(mailbox_element& node) {
}
}
namespace
{
class
invoke_result_visitor_helper
{
public:
invoke_result_visitor_helper
(
response_promise
x
)
:
rp
(
x
)
{
...
...
@@ -429,6 +431,8 @@ private:
local_actor
*
self_
;
};
}
// namespace <anonymous>
void
local_actor
::
handle_response
(
mailbox_element_ptr
&
ptr
,
local_actor
::
pending_response
&
pr
)
{
CAF_ASSERT
(
ptr
!=
nullptr
);
...
...
libcaf_core/src/node_id.cpp
View file @
b1381c27
...
...
@@ -246,7 +246,7 @@ void node_id::from_string(const std::string& str) {
// nop
}
uint8_t
operator
*
()
const
{
return
(
hex_nibble
(
*
i
)
<<
4
)
|
hex_nibble
(
*
(
i
+
1
));
return
static_cast
<
uint8_t
>
(
hex_nibble
(
*
i
)
<<
4
)
|
hex_nibble
(
*
(
i
+
1
));
}
hex_byte_iter
&
operator
++
()
{
i
+=
2
;
...
...
libcaf_core/src/parse_ini.cpp
View file @
b1381c27
...
...
@@ -29,13 +29,13 @@ namespace detail {
void
parse_ini_t
::
operator
()(
std
::
istream
&
input
,
config_consumer
consumer_fun
,
optional
<
std
::
ostream
&>
errors
)
const
{
std
::
string
group
;
std
::
string
line
;
size_t
ln
=
0
;
// line number
// wraps a temporary into an (lvalue) config_value and calls `consumer_fun`
auto
consumer
=
[
&
](
size_t
ln
,
std
::
string
name
,
value
x
)
{
consumer_fun
(
ln
,
std
::
move
(
name
),
x
);
};
std
::
string
group
;
std
::
string
line
;
size_t
ln
=
0
;
// line number
auto
print
=
[
&
](
const
char
*
category
,
const
char
*
str
)
{
if
(
errors
)
*
errors
<<
category
<<
" INI file line "
...
...
libcaf_core/src/scoped_actor.cpp
View file @
b1381c27
...
...
@@ -44,14 +44,14 @@ public:
}
// namespace <anonymous>
scoped_actor
::
scoped_actor
(
actor_system
&
sys
,
bool
hid
den
)
:
context_
{
&
sys
}
{
scoped_actor
::
scoped_actor
(
actor_system
&
sys
,
bool
hid
e
)
:
context_
(
&
sys
)
{
actor_config
cfg
{
&
context_
};
self_
=
make_actor
<
impl
,
strong_actor_ptr
>
(
sys
.
next_actor_id
(),
sys
.
node
(),
&
sys
,
cfg
);
if
(
!
hid
den
)
if
(
!
hid
e
)
prev_
=
CAF_SET_AID
(
self_
->
id
());
CAF_LOG_TRACE
(
CAF_ARG
(
hid
den
));
ptr
()
->
is_registered
(
!
hid
den
);
CAF_LOG_TRACE
(
CAF_ARG
(
hid
e
));
ptr
()
->
is_registered
(
!
hid
e
);
}
scoped_actor
::~
scoped_actor
()
{
...
...
libcaf_core/src/unprofiled.cpp
0 → 100644
View file @
b1381c27
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| 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. *
******************************************************************************/
#include "caf/policy/unprofiled.hpp"
namespace
caf
{
namespace
policy
{
unprofiled
::~
unprofiled
()
{
// nop
}
}
// namespace policy
}
// namespace caf
libcaf_core/src/work_sharing.cpp
0 → 100644
View file @
b1381c27
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| 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. *
******************************************************************************/
#include "caf/policy/work_sharing.hpp"
namespace
caf
{
namespace
policy
{
work_sharing
::~
work_sharing
()
{
// nop
}
}
// namespace policy
}
// namespace caf
libcaf_core/src/work_stealing.cpp
0 → 100644
View file @
b1381c27
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| 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. *
******************************************************************************/
#include "caf/policy/work_stealing.hpp"
namespace
caf
{
namespace
policy
{
work_stealing
::~
work_stealing
()
{
// nop
}
}
// namespace policy
}
// namespace caf
libcaf_core/test/extract.cpp
View file @
b1381c27
...
...
@@ -31,24 +31,6 @@ using namespace caf;
using
std
::
string
;
namespace
{
bool
msg_equals_rec
(
const
message
&
,
size_t
)
{
return
true
;
}
template
<
class
T
,
class
...
Ts
>
bool
msg_equals_rec
(
const
message
&
msg
,
size_t
pos
,
const
T
&
x
,
const
Ts
&
...
xs
)
{
return
msg
.
get_as
<
T
>
(
pos
)
==
x
&&
msg_equals_rec
(
msg
,
pos
+
1
,
xs
...);
}
template
<
class
...
Ts
>
bool
msg_equals
(
const
message
&
msg
,
const
Ts
&
...
xs
)
{
return
msg
.
match_elements
<
Ts
...
>
()
&&
msg_equals_rec
(
msg
,
0
,
xs
...);
}
}
// namespace <anonymous>
CAF_TEST
(
type_sequences
)
{
auto
_64
=
uint64_t
{
64
};
std
::
string
str
=
"str"
;
...
...
@@ -56,9 +38,12 @@ CAF_TEST(type_sequences) {
auto
df
=
[](
double
,
float
)
{
};
auto
fs
=
[](
float
,
const
string
&
)
{
};
auto
iu
=
[](
int
,
uint64_t
)
{
};
CAF_CHECK
(
msg_equals
(
msg
.
extract
(
df
),
str
,
42
,
_64
));
CAF_CHECK
(
msg_equals
(
msg
.
extract
(
fs
),
1.0
,
42
,
_64
));
CAF_CHECK
(
msg_equals
(
msg
.
extract
(
iu
),
1.0
,
2.
f
,
str
));
CAF_CHECK_EQUAL
(
to_string
(
msg
.
extract
(
df
)),
to_string
(
make_message
(
str
,
42
,
_64
)));
CAF_CHECK_EQUAL
(
to_string
(
msg
.
extract
(
fs
)),
to_string
(
make_message
(
1.0
,
42
,
_64
)));
CAF_CHECK_EQUAL
(
to_string
(
msg
.
extract
(
iu
)),
to_string
(
make_message
(
1.0
,
2.
f
,
str
)));
}
CAF_TEST
(
cli_args
)
{
...
...
libcaf_core/test/request_response.cpp
View file @
b1381c27
...
...
@@ -183,11 +183,11 @@ public:
behavior
make_behavior
()
override
{
return
{
[
=
](
gogo_atom
x
)
->
response_promise
{
[
=
](
gogo_atom
gogo
)
->
response_promise
{
auto
rp
=
make_response_promise
();
request
(
buddy
(),
infinite
,
x
).
then
(
[
=
](
ok_atom
x
)
mutable
{
rp
.
deliver
(
x
);
request
(
buddy
(),
infinite
,
gogo
).
then
(
[
=
](
ok_atom
ok
)
mutable
{
rp
.
deliver
(
ok
);
quit
();
}
);
...
...
@@ -429,10 +429,10 @@ CAF_TEST(request_no_then) {
CAF_TEST
(
async_request
)
{
auto
foo
=
system
.
spawn
([](
event_based_actor
*
self
)
->
behavior
{
auto
receiver
=
self
->
spawn
<
linked
>
([](
event_based_actor
*
self
)
->
behavior
{
auto
receiver
=
self
->
spawn
<
linked
>
([](
event_based_actor
*
ptr
)
->
behavior
{
return
{
[
=
](
int
)
{
return
self
->
make_response_promise
();
return
ptr
->
make_response_promise
();
}
};
});
...
...
libcaf_core/test/splitter.cpp
View file @
b1381c27
...
...
@@ -110,22 +110,22 @@ CAF_TEST(untyped_splicing) {
CAF_TEST
(
typed_splicing
)
{
using
namespace
std
::
placeholders
;
auto
x
=
system
.
spawn
(
typed_first_stage
);
auto
y
=
system
.
spawn
(
typed_second_stage
);
auto
x_and_y
=
splice
(
x
,
y
.
bind
(
23.0
,
_1
));
auto
stage0
=
system
.
spawn
(
typed_first_stage
);
auto
stage1
=
system
.
spawn
(
typed_second_stage
);
auto
stages
=
splice
(
stage0
,
stage1
.
bind
(
23.0
,
_1
));
using
expected_type
=
typed_actor
<
replies_to
<
double
>
::
with
<
double
,
double
,
double
>>
;
static_assert
(
std
::
is_same
<
decltype
(
x_and_y
),
expected_type
>::
value
,
static_assert
(
std
::
is_same
<
decltype
(
stages
),
expected_type
>::
value
,
"splice() did not compute the correct result"
);
self
->
request
(
x_and_y
,
infinite
,
42.0
).
receive
(
self
->
request
(
stages
,
infinite
,
42.0
).
receive
(
[](
double
x
,
double
y
,
double
z
)
{
CAF_CHECK_EQUAL
(
x
,
(
42.0
*
2.0
));
CAF_CHECK_EQUAL
(
y
,
(
42.0
*
4.0
));
CAF_CHECK_EQUAL
(
z
,
(
23.0
*
42.0
));
}
);
//
x and y
go out of scope, leaving only the references
// in
x_and_y
, which will also go out of scope
//
stage0 and stage1
go out of scope, leaving only the references
// in
stages
, which will also go out of scope
}
CAF_TEST_FIXTURE_SCOPE_END
()
libcaf_core/test/streambuf.cpp
View file @
b1381c27
...
...
@@ -34,21 +34,21 @@ CAF_TEST(signed_arraybuf) {
CAF_CHECK_EQUAL
(
ab
.
sgetc
(),
'T'
);
std
::
string
buf
;
buf
.
resize
(
3
);
size_t
got
=
ab
.
sgetn
(
&
buf
[
0
],
3
);
CAF_CHECK_EQUAL
(
got
,
3
u
);
auto
got
=
ab
.
sgetn
(
&
buf
[
0
],
3
);
CAF_CHECK_EQUAL
(
got
,
3
);
CAF_CHECK_EQUAL
(
buf
,
"The"
);
CAF_CHECK_EQUAL
(
ab
.
sgetc
(),
' '
);
// Exhaust the stream.
buf
.
resize
(
data
.
size
());
got
=
ab
.
sgetn
(
&
buf
[
0
]
+
3
,
data
.
size
()
-
3
);
CAF_CHECK_EQUAL
(
got
,
data
.
size
()
-
3
);
got
=
ab
.
sgetn
(
&
buf
[
0
]
+
3
,
static_cast
<
std
::
streamsize
>
(
data
.
size
()
-
3
)
);
CAF_CHECK_EQUAL
(
static_cast
<
size_t
>
(
got
)
,
data
.
size
()
-
3
);
CAF_CHECK_EQUAL
(
data
,
buf
);
CAF_CHECK_EQUAL
(
ab
.
in_avail
(),
0
);
// No more.
auto
c
=
ab
.
sgetc
();
CAF_CHECK_EQUAL
(
c
,
charbuf
::
traits_type
::
eof
());
// Reset the stream and write into it.
ab
.
setbuf
(
&
data
[
0
],
data
.
size
(
));
ab
.
setbuf
(
&
data
[
0
],
static_cast
<
std
::
streamsize
>
(
data
.
size
()
));
CAF_CHECK_EQUAL
(
static_cast
<
size_t
>
(
ab
.
in_avail
()),
data
.
size
());
auto
put
=
ab
.
sputn
(
"One"
,
3
);
CAF_CHECK_EQUAL
(
put
,
3
);
...
...
@@ -77,7 +77,7 @@ CAF_TEST(containerbuf) {
// Write some data.
std
::
vector
<
char
>
buf
;
vectorbuf
vb
{
buf
};
auto
put
=
vb
.
sputn
(
data
.
data
(),
data
.
size
(
));
auto
put
=
vb
.
sputn
(
data
.
data
(),
static_cast
<
std
::
streamsize
>
(
data
.
size
()
));
CAF_CHECK_EQUAL
(
static_cast
<
size_t
>
(
put
),
data
.
size
());
put
=
vb
.
sputn
(
";"
,
1
);
CAF_CHECK_EQUAL
(
put
,
1
);
...
...
@@ -103,8 +103,8 @@ CAF_TEST(containerbuf) {
buf
.
clear
();
containerbuf
<
std
::
string
>
sib2
{
data
};
buf
.
resize
(
data
.
size
());
size_t
got
=
sib2
.
sgetn
(
&
buf
[
0
],
buf
.
size
(
));
CAF_CHECK_EQUAL
(
got
,
data
.
size
());
auto
got
=
sib2
.
sgetn
(
&
buf
[
0
],
static_cast
<
std
::
streamsize
>
(
buf
.
size
()
));
CAF_CHECK_EQUAL
(
static_cast
<
size_t
>
(
got
)
,
data
.
size
());
CAF_CHECK_EQUAL
(
buf
.
size
(),
data
.
size
());
CAF_CHECK
(
std
::
equal
(
buf
.
begin
(),
buf
.
end
(),
data
.
begin
()
/*, data.end() */
));
}
libcaf_io/caf/io/middleman.hpp
View file @
b1381c27
...
...
@@ -146,13 +146,14 @@ public:
/// Adds a new hook to the middleman.
template
<
class
C
,
typename
...
Ts
>
void
add_hook
(
Ts
&&
...
xs
)
{
C
*
add_hook
(
Ts
&&
...
xs
)
{
// if only we could move a unique_ptr into a lambda in C++11
auto
ptr
=
new
C
(
system_
,
std
::
forward
<
Ts
>
(
xs
)...);
backend
().
dispatch
([
=
]
{
ptr
->
next
.
swap
(
hooks_
);
hooks_
.
reset
(
ptr
);
});
return
ptr
;
}
/// Returns whether this middleman has any hooks installed.
...
...
libcaf_io/src/basp_broker.cpp
View file @
b1381c27
...
...
@@ -600,6 +600,7 @@ behavior basp_broker::make_behavior() {
}
catch
(
std
::
exception
&
e
)
{
CAF_LOG_DEBUG
(
"failed to assign scribe from handle: "
<<
e
.
what
());
CAF_IGNORE_UNUSED
(
e
);
rp
.
deliver
(
sec
::
failed_to_assign_scribe_from_handle
);
return
;
}
...
...
libcaf_io/src/middleman_actor.cpp
View file @
b1381c27
...
...
@@ -132,16 +132,16 @@ public:
cached_
.
emplace
(
key
,
std
::
make_tuple
(
nid
,
addr
,
sigs
));
auto
res
=
make_message
(
ok_atom
::
value
,
std
::
move
(
nid
),
std
::
move
(
addr
),
std
::
move
(
sigs
));
for
(
auto
&
x
:
i
->
second
)
x
.
deliver
(
res
);
for
(
auto
&
promise
:
i
->
second
)
promise
.
deliver
(
res
);
pending_
.
erase
(
i
);
},
[
=
](
error
&
err
)
{
auto
i
=
pending_
.
find
(
key
);
if
(
i
==
pending_
.
end
())
return
;
for
(
auto
&
x
:
i
->
second
)
x
.
deliver
(
err
);
for
(
auto
&
promise
:
i
->
second
)
promise
.
deliver
(
err
);
pending_
.
erase
(
i
);
}
);
...
...
libcaf_io/test/basp.cpp
View file @
b1381c27
...
...
@@ -469,7 +469,7 @@ CAF_TEST(non_empty_server_handshake) {
buffer
buf
;
instance
().
add_published_actor
(
4242
,
actor_cast
<
strong_actor_ptr
>
(
self
()),
{
"caf::replies_to<@u16>::with<@u16>"
});
instance
().
write_server_handshake
(
mpx
(),
buf
,
4242
);
instance
().
write_server_handshake
(
mpx
(),
buf
,
uint16_t
{
4242
}
);
buffer
expected_buf
;
basp
::
header
expected
{
basp
::
message_type
::
server_handshake
,
0
,
basp
::
version
,
this_node
(),
invalid_node_id
,
...
...
libcaf_io/test/remote_actor.cpp
View file @
b1381c27
...
...
@@ -86,9 +86,8 @@ caf::behavior make_ping_behavior(caf::event_based_actor* self,
std
::
string
to_string
(
const
std
::
vector
<
int
>&
vec
)
{
std
::
ostringstream
os
;
for
(
auto
i
=
0
;
i
+
1
<
static_cast
<
int
>
(
vec
.
size
());
++
i
)
{
for
(
size_t
i
=
0
;
i
+
1
<
vec
.
size
();
++
i
)
os
<<
vec
[
i
]
<<
", "
;
}
os
<<
vec
.
back
();
return
os
.
str
();
}
...
...
@@ -106,14 +105,12 @@ caf::behavior make_sort_behavior() {
caf
::
behavior
make_sort_requester_behavior
(
caf
::
event_based_actor
*
self
,
caf
::
actor
sorter
)
{
std
::
vector
<
int
>
vec
=
{
5
,
4
,
3
,
2
,
1
};
self
->
send
(
sorter
,
std
::
move
(
vec
));
self
->
send
(
sorter
,
std
::
vector
<
int
>
{
5
,
4
,
3
,
2
,
1
});
return
{
[
=
](
const
std
::
vector
<
int
>&
vec
)
{
CAF_MESSAGE
(
"sort requester received: "
<<
to_string
(
vec
));
for
(
int
i
=
1
;
i
<=
5
;
++
i
)
{
CAF_CHECK_EQUAL
(
i
,
vec
[
i
-
1
]);
}
for
(
size_t
i
=
1
;
i
<
vec
.
size
();
++
i
)
CAF_CHECK_EQUAL
(
static_cast
<
int
>
(
i
),
vec
[
i
-
1
]);
self
->
send_exit
(
sorter
,
caf
::
exit_reason
::
user_shutdown
);
self
->
quit
();
}
...
...
tools/caf-run.cpp
View file @
b1381c27
...
...
@@ -214,12 +214,12 @@ void bootstrap(actor_system& system,
std
::
string
slaveslist
;
for
(
size_t
i
=
0
;
i
<
slaves
.
size
();
++
i
)
{
self
->
receive
(
[
&
](
ok_atom
,
const
string
&
host
,
uint16_t
port
)
{
[
&
](
ok_atom
,
const
string
&
host
,
uint16_t
slave_
port
)
{
if
(
!
slaveslist
.
empty
())
slaveslist
+=
','
;
slaveslist
+=
host
;
slaveslist
+=
'/'
;
slaveslist
+=
std
::
to_string
(
port
);
slaveslist
+=
std
::
to_string
(
slave_
port
);
},
[](
const
string
&
node
)
{
cerr
<<
"unable to launch process via SSH at node "
<<
node
<<
endl
;
...
...
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