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
ad53b9f9
Commit
ad53b9f9
authored
Jun 20, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new get_or API for scheduler setup
parent
324d1b7c
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
115 additions
and
53 deletions
+115
-53
libcaf_core/caf/actor_system_config.hpp
libcaf_core/caf/actor_system_config.hpp
+6
-6
libcaf_core/caf/all.hpp
libcaf_core/caf/all.hpp
+1
-0
libcaf_core/caf/config_option_adder.hpp
libcaf_core/caf/config_option_adder.hpp
+5
-0
libcaf_core/caf/defaults.hpp
libcaf_core/caf/defaults.hpp
+1
-0
libcaf_core/caf/make_config_option.hpp
libcaf_core/caf/make_config_option.hpp
+6
-0
libcaf_core/caf/scheduler/profiled_coordinator.hpp
libcaf_core/caf/scheduler/profiled_coordinator.hpp
+11
-8
libcaf_core/src/abstract_coordinator.cpp
libcaf_core/src/abstract_coordinator.cpp
+13
-14
libcaf_core/src/actor_system.cpp
libcaf_core/src/actor_system.cpp
+7
-5
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+12
-6
libcaf_core/src/config_option_adder.cpp
libcaf_core/src/config_option_adder.cpp
+7
-2
libcaf_core/src/defaults.cpp
libcaf_core/src/defaults.cpp
+1
-0
libcaf_core/src/group_manager.cpp
libcaf_core/src/group_manager.cpp
+1
-1
libcaf_core/src/make_config_option.cpp
libcaf_core/src/make_config_option.cpp
+26
-2
libcaf_core/test/actor_lifetime.cpp
libcaf_core/test/actor_lifetime.cpp
+1
-1
libcaf_core/test/logger.cpp
libcaf_core/test/logger.cpp
+1
-1
libcaf_core/test/request_timeout.cpp
libcaf_core/test/request_timeout.cpp
+1
-1
libcaf_core/test/simple_timeout.cpp
libcaf_core/test/simple_timeout.cpp
+1
-1
libcaf_core/test/thread_hook.cpp
libcaf_core/test/thread_hook.cpp
+5
-2
libcaf_io/caf/io/network/default_multiplexer.hpp
libcaf_io/caf/io/network/default_multiplexer.hpp
+3
-0
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+6
-3
No files found.
libcaf_core/caf/actor_system_config.hpp
View file @
ad53b9f9
...
@@ -304,12 +304,12 @@ public:
...
@@ -304,12 +304,12 @@ public:
// -- scheduling parameters --------------------------------------------------
// -- scheduling parameters --------------------------------------------------
atom_value
scheduler_policy
;
atom_value
scheduler_policy
CAF_DEPRECATED
;
size_t
scheduler_max_threads
;
size_t
scheduler_max_threads
CAF_DEPRECATED
;
size_t
scheduler_max_throughput
;
size_t
scheduler_max_throughput
CAF_DEPRECATED
;
bool
scheduler_enable_profiling
;
bool
scheduler_enable_profiling
CAF_DEPRECATED
;
size_t
scheduler_profiling_ms_resolution
;
size_t
scheduler_profiling_ms_resolution
CAF_DEPRECATED
;
std
::
string
scheduler_profiling_output_file
;
std
::
string
scheduler_profiling_output_file
CAF_DEPRECATED
;
// -- work-stealing parameters -----------------------------------------------
// -- work-stealing parameters -----------------------------------------------
...
...
libcaf_core/caf/all.hpp
View file @
ad53b9f9
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include "caf/message.hpp"
#include "caf/message.hpp"
#include "caf/node_id.hpp"
#include "caf/node_id.hpp"
#include "caf/behavior.hpp"
#include "caf/behavior.hpp"
#include "caf/defaults.hpp"
#include "caf/duration.hpp"
#include "caf/duration.hpp"
#include "caf/expected.hpp"
#include "caf/expected.hpp"
#include "caf/exec_main.hpp"
#include "caf/exec_main.hpp"
...
...
libcaf_core/caf/config_option_adder.hpp
View file @
ad53b9f9
...
@@ -56,6 +56,11 @@ public:
...
@@ -56,6 +56,11 @@ public:
config_option_adder
&
add_us
(
size_t
&
ref
,
const
char
*
name
,
config_option_adder
&
add_us
(
size_t
&
ref
,
const
char
*
name
,
const
char
*
description
);
const
char
*
description
);
/// For backward compatibility only. Do not use for new code!
/// @private
config_option_adder
&
add_ms
(
size_t
&
ref
,
const
char
*
name
,
const
char
*
description
);
private:
private:
// -- properties -------------------------------------------------------------
// -- properties -------------------------------------------------------------
...
...
libcaf_core/caf/defaults.hpp
View file @
ad53b9f9
...
@@ -40,6 +40,7 @@ extern const timespan credit_round_interval;
...
@@ -40,6 +40,7 @@ extern const timespan credit_round_interval;
namespace
scheduler
{
namespace
scheduler
{
extern
const
atom_value
policy
;
extern
const
atom_value
policy
;
extern
const
char
*
profiling_output_file
;
extern
const
size_t
max_threads
;
extern
const
size_t
max_threads
;
extern
const
size_t
max_throughput
;
extern
const
size_t
max_throughput
;
extern
const
timespan
profiling_resolution
;
extern
const
timespan
profiling_resolution
;
...
...
libcaf_core/caf/make_config_option.hpp
View file @
ad53b9f9
...
@@ -79,6 +79,12 @@ config_option make_us_resolution_config_option(size_t& storage,
...
@@ -79,6 +79,12 @@ config_option make_us_resolution_config_option(size_t& storage,
const
char
*
name
,
const
char
*
name
,
const
char
*
description
);
const
char
*
description
);
// Reads timespans, but stores an integer representing millisecond resolution.
config_option
make_ms_resolution_config_option
(
size_t
&
storage
,
const
char
*
category
,
const
char
*
name
,
const
char
*
description
);
// -- specializations for common types -----------------------------------------
// -- specializations for common types -----------------------------------------
#define CAF_SPECIALIZE_MAKE_CONFIG_OPTION(type) \
#define CAF_SPECIALIZE_MAKE_CONFIG_OPTION(type) \
...
...
libcaf_core/caf/scheduler/profiled_coordinator.hpp
View file @
ad53b9f9
...
@@ -38,13 +38,11 @@
...
@@ -38,13 +38,11 @@
#include <unordered_map>
#include <unordered_map>
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/defaults.hpp"
#include "caf/scheduler/coordinator.hpp"
#include "caf/logger.hpp"
#include "caf/policy/profiled.hpp"
#include "caf/policy/profiled.hpp"
#include "caf/policy/work_stealing.hpp"
#include "caf/policy/work_stealing.hpp"
#include "caf/scheduler/coordinator.hpp"
#include "caf/logger.hpp"
namespace
caf
{
namespace
caf
{
namespace
scheduler
{
namespace
scheduler
{
...
@@ -178,14 +176,19 @@ public:
...
@@ -178,14 +176,19 @@ public:
}
}
void
init
(
actor_system_config
&
cfg
)
override
{
void
init
(
actor_system_config
&
cfg
)
override
{
namespace
sr
=
defaults
::
scheduler
;
super
::
init
(
cfg
);
super
::
init
(
cfg
);
file_
.
open
(
cfg
.
scheduler_profiling_output_file
);
auto
fname
=
get_or
(
cfg
,
"scheduler.profiling-output-file"
,
sr
::
profiling_output_file
);
file_
.
open
(
fname
);
if
(
!
file_
)
if
(
!
file_
)
std
::
cerr
<<
R"([WARNING] could not open file ")"
std
::
cerr
<<
R"([WARNING] could not open file ")"
<<
cfg
.
scheduler_profiling_output_fil
e
<<
fnam
e
<<
R"(" (no profiler output will be generated))"
<<
R"(" (no profiler output will be generated))"
<<
std
::
endl
;
<<
std
::
endl
;
resolution_
=
msec
{
cfg
.
scheduler_profiling_ms_resolution
};
auto
res
=
get_or
(
cfg
,
"scheduler.profiling-resolution"
,
sr
::
profiling_resolution
);
resolution_
=
std
::
chrono
::
duration_cast
<
msec
>
(
res
);
}
}
void
start
()
override
{
void
start
()
override
{
...
...
libcaf_core/src/abstract_coordinator.cpp
View file @
ad53b9f9
...
@@ -27,22 +27,20 @@
...
@@ -27,22 +27,20 @@
#include <unordered_map>
#include <unordered_map>
#include <condition_variable>
#include <condition_variable>
#include "caf/send.hpp"
#include "caf/actor_ostream.hpp"
#include "caf/actor_system.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/after.hpp"
#include "caf/after.hpp"
#include "caf/
other
s.hpp"
#include "caf/
default
s.hpp"
#include "caf/duration.hpp"
#include "caf/duration.hpp"
#include "caf/actor_system.hpp"
#include "caf/logger.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/others.hpp"
#include "caf/actor_ostream.hpp"
#include "caf/policy/work_stealing.hpp"
#include "caf/system_messages.hpp"
#include "caf/scheduled_actor.hpp"
#include "caf/scheduled_actor.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/scheduler/coordinator.hpp"
#include "caf/scheduler/coordinator.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/policy/work_stealing.hpp"
#include "caf/send.hpp"
#include "caf/system_messages.hpp"
#include "caf/logger.hpp"
namespace
caf
{
namespace
caf
{
namespace
scheduler
{
namespace
scheduler
{
...
@@ -251,8 +249,9 @@ void abstract_coordinator::start() {
...
@@ -251,8 +249,9 @@ void abstract_coordinator::start() {
}
}
void
abstract_coordinator
::
init
(
actor_system_config
&
cfg
)
{
void
abstract_coordinator
::
init
(
actor_system_config
&
cfg
)
{
max_throughput_
=
cfg
.
scheduler_max_throughput
;
namespace
sr
=
defaults
::
scheduler
;
num_workers_
=
cfg
.
scheduler_max_threads
;
max_throughput_
=
get_or
(
cfg
,
"scheduler.max-throughput"
,
sr
::
max_throughput
);
num_workers_
=
get_or
(
cfg
,
"scheduler.max-threads"
,
sr
::
max_threads
);
}
}
actor_system
::
module
::
id_t
abstract_coordinator
::
id
()
const
{
actor_system
::
module
::
id_t
abstract_coordinator
::
id
()
const
{
...
...
libcaf_core/src/actor_system.cpp
View file @
ad53b9f9
...
@@ -239,16 +239,18 @@ actor_system::actor_system(actor_system_config& cfg)
...
@@ -239,16 +239,18 @@ actor_system::actor_system(actor_system_config& cfg)
profiled_sharing
=
0x0102
profiled_sharing
=
0x0102
};
};
sched_conf
sc
=
stealing
;
sched_conf
sc
=
stealing
;
if
(
cfg
.
scheduler_policy
==
atom
(
"sharing"
))
namespace
sr
=
defaults
::
scheduler
;
auto
sr_policy
=
get_or
(
cfg
,
"scheduler.policy"
,
sr
::
policy
);
if
(
sr_policy
==
atom
(
"sharing"
))
sc
=
sharing
;
sc
=
sharing
;
else
if
(
cfg
.
schedule
r_policy
==
atom
(
"testing"
))
else
if
(
s
r_policy
==
atom
(
"testing"
))
sc
=
testing
;
sc
=
testing
;
else
if
(
cfg
.
schedule
r_policy
!=
atom
(
"stealing"
))
else
if
(
s
r_policy
!=
atom
(
"stealing"
))
std
::
cerr
<<
"[WARNING] "
<<
deep_to_string
(
cfg
.
schedule
r_policy
)
std
::
cerr
<<
"[WARNING] "
<<
deep_to_string
(
s
r_policy
)
<<
" is an unrecognized scheduler pollicy, "
<<
" is an unrecognized scheduler pollicy, "
"falling back to 'stealing' (i.e. work-stealing)"
"falling back to 'stealing' (i.e. work-stealing)"
<<
std
::
endl
;
<<
std
::
endl
;
if
(
cfg
.
scheduler_enable_profiling
)
if
(
get_or
(
cfg
,
"scheduler.enable-profiling"
,
false
)
)
sc
=
static_cast
<
sched_conf
>
(
sc
|
profiled
);
sc
=
static_cast
<
sched_conf
>
(
sc
|
profiled
);
switch
(
sc
)
{
switch
(
sc
)
{
default:
// any invalid configuration falls back to work stealing
default:
// any invalid configuration falls back to work stealing
...
...
libcaf_core/src/actor_system_config.cpp
View file @
ad53b9f9
...
@@ -60,11 +60,15 @@ actor_system_config::actor_system_config()
...
@@ -60,11 +60,15 @@ actor_system_config::actor_system_config()
streaming_desired_batch_complexity_us
=
50
;
streaming_desired_batch_complexity_us
=
50
;
streaming_max_batch_delay_us
=
50000
;
streaming_max_batch_delay_us
=
50000
;
streaming_credit_round_interval_us
=
100000
;
streaming_credit_round_interval_us
=
100000
;
scheduler_policy
=
atom
(
"stealing"
);
namespace
sr
=
defaults
::
scheduler
;
scheduler_max_threads
=
std
::
max
(
std
::
thread
::
hardware_concurrency
(),
4u
);
auto
to_ms
=
[](
timespan
x
)
{
scheduler_max_throughput
=
std
::
numeric_limits
<
size_t
>::
max
();
return
static_cast
<
size_t
>
(
x
.
count
()
/
1000000
);
};
scheduler_policy
=
sr
::
policy
;
scheduler_max_threads
=
sr
::
max_threads
;
scheduler_max_throughput
=
sr
::
max_throughput
;
scheduler_enable_profiling
=
false
;
scheduler_enable_profiling
=
false
;
scheduler_profiling_ms_resolution
=
100
;
scheduler_profiling_ms_resolution
=
to_ms
(
sr
::
profiling_resolution
)
;
namespace
ws
=
defaults
::
work_stealing
;
namespace
ws
=
defaults
::
work_stealing
;
auto
to_us
=
[](
timespan
x
)
{
auto
to_us
=
[](
timespan
x
)
{
return
static_cast
<
size_t
>
(
x
.
count
()
/
1000
);
return
static_cast
<
size_t
>
(
x
.
count
()
/
1000
);
...
@@ -112,8 +116,10 @@ actor_system_config::actor_system_config()
...
@@ -112,8 +116,10 @@ actor_system_config::actor_system_config()
"sets the maximum number of messages an actor consumes before yielding"
)
"sets the maximum number of messages an actor consumes before yielding"
)
.
add
(
scheduler_enable_profiling
,
"enable-profiling"
,
.
add
(
scheduler_enable_profiling
,
"enable-profiling"
,
"enables or disables profiler output"
)
"enables or disables profiler output"
)
.
add
(
scheduler_profiling_ms_resolution
,
"profiling-ms-resolution"
,
.
add_ms
(
scheduler_profiling_ms_resolution
,
"profiling-ms-resolution"
,
"sets the rate in ms in which the profiler collects data"
)
"deprecated (use profiling-resolution instead)"
)
.
add_ms
(
scheduler_profiling_ms_resolution
,
"profiling-resolution"
,
"sets the rate in ms in which the profiler collects data"
)
.
add
(
scheduler_profiling_output_file
,
"profiling-output-file"
,
.
add
(
scheduler_profiling_output_file
,
"profiling-output-file"
,
"sets the output file for the profiler"
);
"sets the output file for the profiler"
);
opt_group
(
custom_options_
,
"work-stealing"
)
opt_group
(
custom_options_
,
"work-stealing"
)
...
...
libcaf_core/src/config_option_adder.cpp
View file @
ad53b9f9
...
@@ -35,13 +35,18 @@ config_option_adder& config_option_adder::add_neg(bool& ref, const char* name,
...
@@ -35,13 +35,18 @@ config_option_adder& config_option_adder::add_neg(bool& ref, const char* name,
name
,
description
));
name
,
description
));
}
}
config_option_adder
&
config_option_adder
::
add_us
(
size_t
&
ref
,
config_option_adder
&
config_option_adder
::
add_us
(
size_t
&
ref
,
const
char
*
name
,
const
char
*
name
,
const
char
*
description
)
{
const
char
*
description
)
{
return
add_impl
(
make_us_resolution_config_option
(
ref
,
category_
,
return
add_impl
(
make_us_resolution_config_option
(
ref
,
category_
,
name
,
description
));
name
,
description
));
}
}
config_option_adder
&
config_option_adder
::
add_ms
(
size_t
&
ref
,
const
char
*
name
,
const
char
*
description
)
{
return
add_impl
(
make_ms_resolution_config_option
(
ref
,
category_
,
name
,
description
));
}
config_option_adder
&
config_option_adder
::
add_impl
(
config_option
&&
opt
)
{
config_option_adder
&
config_option_adder
::
add_impl
(
config_option
&&
opt
)
{
xs_
.
add
(
std
::
move
(
opt
));
xs_
.
add
(
std
::
move
(
opt
));
return
*
this
;
return
*
this
;
...
...
libcaf_core/src/defaults.cpp
View file @
ad53b9f9
...
@@ -52,6 +52,7 @@ const timespan credit_round_interval = ms(10);
...
@@ -52,6 +52,7 @@ const timespan credit_round_interval = ms(10);
namespace
scheduler
{
namespace
scheduler
{
const
atom_value
policy
=
atom
(
"stealing"
);
const
atom_value
policy
=
atom
(
"stealing"
);
const
char
*
profiling_output_file
=
""
;
const
size_t
max_threads
=
std
::
max
(
std
::
thread
::
hardware_concurrency
(),
4u
);
const
size_t
max_threads
=
std
::
max
(
std
::
thread
::
hardware_concurrency
(),
4u
);
const
size_t
max_throughput
=
std
::
numeric_limits
<
size_t
>::
max
();
const
size_t
max_throughput
=
std
::
numeric_limits
<
size_t
>::
max
();
const
timespan
profiling_resolution
=
ms
(
100
);
const
timespan
profiling_resolution
=
ms
(
100
);
...
...
libcaf_core/src/group_manager.cpp
View file @
ad53b9f9
...
@@ -55,7 +55,7 @@ void await_all_locals_down(actor_system& sys, std::initializer_list<actor> xs) {
...
@@ -55,7 +55,7 @@ void await_all_locals_down(actor_system& sys, std::initializer_list<actor> xs) {
ys
.
push_back
(
x
);
ys
.
push_back
(
x
);
}
}
// Don't block when using the test coordinator.
// Don't block when using the test coordinator.
if
(
sys
.
config
().
scheduler_policy
!=
atom
(
"testing"
))
if
(
atom
(
"testing"
)
!=
get_or
(
sys
.
config
(),
"scheduler.policy"
,
atom
(
""
)
))
self
->
wait_for
(
ys
);
self
->
wait_for
(
ys
);
}
}
...
...
libcaf_core/src/make_config_option.cpp
View file @
ad53b9f9
...
@@ -94,7 +94,7 @@ meta_state bool_meta{bool_check, bool_store, bool_get,
...
@@ -94,7 +94,7 @@ meta_state bool_meta{bool_check, bool_store, bool_get,
meta_state
bool_neg_meta
{
bool_check
,
bool_store_neg
,
bool_get_neg
,
meta_state
bool_neg_meta
{
bool_check
,
bool_store_neg
,
bool_get_neg
,
detail
::
type_name
<
bool
>
()};
detail
::
type_name
<
bool
>
()};
meta_state
entangled
_meta
{
meta_state
us_res
_meta
{
[](
const
config_value
&
x
)
->
error
{
[](
const
config_value
&
x
)
->
error
{
if
(
holds_alternative
<
timespan
>
(
x
))
if
(
holds_alternative
<
timespan
>
(
x
))
return
none
;
return
none
;
...
@@ -111,6 +111,23 @@ meta_state entangled_meta{
...
@@ -111,6 +111,23 @@ meta_state entangled_meta{
detail
::
type_name
<
timespan
>
()
detail
::
type_name
<
timespan
>
()
};
};
meta_state
ms_res_meta
{
[](
const
config_value
&
x
)
->
error
{
if
(
holds_alternative
<
timespan
>
(
x
))
return
none
;
return
make_error
(
pec
::
type_mismatch
);
},
[](
void
*
ptr
,
const
config_value
&
x
)
{
*
static_cast
<
size_t
*>
(
ptr
)
=
get
<
timespan
>
(
x
).
count
()
/
1000000
;
},
[](
const
void
*
ptr
)
->
config_value
{
auto
ival
=
static_cast
<
int64_t
>
(
*
static_cast
<
const
size_t
*>
(
ptr
));
timespan
val
{
ival
/
1000000
};
return
config_value
{
val
};
},
detail
::
type_name
<
timespan
>
()
};
DEFAULT_META
(
atom_value
);
DEFAULT_META
(
atom_value
);
DEFAULT_META
(
size_t
);
DEFAULT_META
(
size_t
);
...
@@ -129,7 +146,14 @@ config_option make_us_resolution_config_option(size_t& storage,
...
@@ -129,7 +146,14 @@ config_option make_us_resolution_config_option(size_t& storage,
const
char
*
category
,
const
char
*
category
,
const
char
*
name
,
const
char
*
name
,
const
char
*
description
)
{
const
char
*
description
)
{
return
{
category
,
name
,
description
,
&
entangled_meta
,
&
storage
};
return
{
category
,
name
,
description
,
&
us_res_meta
,
&
storage
};
}
config_option
make_ms_resolution_config_option
(
size_t
&
storage
,
const
char
*
category
,
const
char
*
name
,
const
char
*
description
)
{
return
{
category
,
name
,
description
,
&
ms_res_meta
,
&
storage
};
}
}
DEFAULT_MAKE_IMPL
(
atom_value
)
DEFAULT_MAKE_IMPL
(
atom_value
)
...
...
libcaf_core/test/actor_lifetime.cpp
View file @
ad53b9f9
...
@@ -118,7 +118,7 @@ behavior tester(event_based_actor* self, const actor& aut) {
...
@@ -118,7 +118,7 @@ behavior tester(event_based_actor* self, const actor& aut) {
struct
config
:
actor_system_config
{
struct
config
:
actor_system_config
{
config
()
{
config
()
{
s
cheduler_policy
=
atom
(
"testing"
);
s
et
(
"scheduler.policy"
,
atom
(
"testing"
)
);
}
}
};
};
...
...
libcaf_core/test/logger.cpp
View file @
ad53b9f9
...
@@ -34,7 +34,7 @@ namespace {
...
@@ -34,7 +34,7 @@ namespace {
struct
fixture
{
struct
fixture
{
fixture
()
{
fixture
()
{
cfg
.
s
cheduler_policy
=
caf
::
atom
(
"testing"
);
cfg
.
s
et
(
"scheduler.policy"
,
atom
(
"testing"
)
);
}
}
void
add
(
logger
::
field_type
kind
)
{
void
add
(
logger
::
field_type
kind
)
{
...
...
libcaf_core/test/request_timeout.cpp
View file @
ad53b9f9
...
@@ -265,7 +265,7 @@ behavior ping_multiplexed3(ping_actor* self, bool* had_timeout,
...
@@ -265,7 +265,7 @@ behavior ping_multiplexed3(ping_actor* self, bool* had_timeout,
struct
config
:
actor_system_config
{
struct
config
:
actor_system_config
{
config
()
{
config
()
{
s
cheduler_policy
=
atom
(
"testing"
);
s
et
(
"scheduler.policy"
,
atom
(
"testing"
)
);
}
}
};
};
...
...
libcaf_core/test/simple_timeout.cpp
View file @
ad53b9f9
...
@@ -72,7 +72,7 @@ timer::behavior_type timer_impl2(timer::pointer self) {
...
@@ -72,7 +72,7 @@ timer::behavior_type timer_impl2(timer::pointer self) {
struct
config
:
actor_system_config
{
struct
config
:
actor_system_config
{
config
()
{
config
()
{
s
cheduler_policy
=
atom
(
"testing"
);
s
et
(
"scheduler.policy"
,
atom
(
"testing"
)
);
}
}
};
};
...
...
libcaf_core/test/thread_hook.cpp
View file @
ad53b9f9
...
@@ -117,7 +117,8 @@ CAF_TEST_FIXTURE_SCOPE(counting_hook, fixture<counting_thread_hook>)
...
@@ -117,7 +117,8 @@ CAF_TEST_FIXTURE_SCOPE(counting_hook, fixture<counting_thread_hook>)
CAF_TEST
(
counting_system_without_actor
)
{
CAF_TEST
(
counting_system_without_actor
)
{
assumed_init_calls
=
1
;
assumed_init_calls
=
1
;
assumed_thread_count
=
cfg
.
scheduler_max_threads
;
assumed_thread_count
=
get_or
(
cfg
,
"scheduler.max-threads"
,
defaults
::
scheduler
::
max_threads
);
auto
&
sched
=
sys
.
scheduler
();
auto
&
sched
=
sys
.
scheduler
();
if
(
sched
.
detaches_utility_actors
())
if
(
sched
.
detaches_utility_actors
())
assumed_thread_count
+=
sched
.
num_utility_actors
();
assumed_thread_count
+=
sched
.
num_utility_actors
();
...
@@ -125,7 +126,9 @@ CAF_TEST(counting_system_without_actor) {
...
@@ -125,7 +126,9 @@ CAF_TEST(counting_system_without_actor) {
CAF_TEST
(
counting_system_with_actor
)
{
CAF_TEST
(
counting_system_with_actor
)
{
assumed_init_calls
=
1
;
assumed_init_calls
=
1
;
assumed_thread_count
=
cfg
.
scheduler_max_threads
+
1
;
assumed_thread_count
=
get_or
(
cfg
,
"scheduler.max-threads"
,
defaults
::
scheduler
::
max_threads
)
+
1
;
auto
&
sched
=
sys
.
scheduler
();
auto
&
sched
=
sys
.
scheduler
();
if
(
sched
.
detaches_utility_actors
())
if
(
sched
.
detaches_utility_actors
())
assumed_thread_count
+=
sched
.
num_utility_actors
();
assumed_thread_count
+=
sched
.
num_utility_actors
();
...
...
libcaf_io/caf/io/network/default_multiplexer.hpp
View file @
ad53b9f9
...
@@ -504,6 +504,9 @@ private:
...
@@ -504,6 +504,9 @@ private:
/// Sequential ids for handles of datagram servants
/// Sequential ids for handles of datagram servants
int64_t
servant_ids_
;
int64_t
servant_ids_
;
/// Maximum messages per resume run.
size_t
max_throughput_
;
};
};
inline
connection_handle
conn_hdl_from_socket
(
native_socket
fd
)
{
inline
connection_handle
conn_hdl_from_socket
(
native_socket
fd
)
{
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
ad53b9f9
...
@@ -292,7 +292,8 @@ namespace network {
...
@@ -292,7 +292,8 @@ namespace network {
epollfd_
(
invalid_native_socket
),
epollfd_
(
invalid_native_socket
),
shadow_
(
1
),
shadow_
(
1
),
pipe_reader_
(
*
this
),
pipe_reader_
(
*
this
),
servant_ids_
(
0
)
{
servant_ids_
(
0
),
max_throughput_
(
0
){
init
();
init
();
epollfd_
=
epoll_create1
(
EPOLL_CLOEXEC
);
epollfd_
=
epoll_create1
(
EPOLL_CLOEXEC
);
if
(
epollfd_
==
-
1
)
{
if
(
epollfd_
==
-
1
)
{
...
@@ -843,6 +844,9 @@ void default_multiplexer::init() {
...
@@ -843,6 +844,9 @@ void default_multiplexer::init() {
CAF_CRITICAL
(
"WSAStartup failed"
);
CAF_CRITICAL
(
"WSAStartup failed"
);
}
}
# endif
# endif
namespace
sr
=
defaults
::
scheduler
;
max_throughput_
=
get_or
(
system
().
config
(),
"scheduler.max-throughput"
,
sr
::
max_throughput
);
}
}
bool
default_multiplexer
::
poll_once
(
bool
block
)
{
bool
default_multiplexer
::
poll_once
(
bool
block
)
{
...
@@ -870,8 +874,7 @@ bool default_multiplexer::poll_once(bool block) {
...
@@ -870,8 +874,7 @@ bool default_multiplexer::poll_once(bool block) {
void
default_multiplexer
::
resume
(
intrusive_ptr
<
resumable
>
ptr
)
{
void
default_multiplexer
::
resume
(
intrusive_ptr
<
resumable
>
ptr
)
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
auto
mt
=
system
().
config
().
scheduler_max_throughput
;
switch
(
ptr
->
resume
(
this
,
max_throughput_
))
{
switch
(
ptr
->
resume
(
this
,
mt
))
{
case
resumable
:
:
resume_later
:
case
resumable
:
:
resume_later
:
// Delay resumable until next cycle.
// Delay resumable until next cycle.
internally_posted_
.
emplace_back
(
ptr
.
release
(),
false
);
internally_posted_
.
emplace_back
(
ptr
.
release
(),
false
);
...
...
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