Commit 11d1732a authored by Dominik Charousset's avatar Dominik Charousset

Remove blocking_api flag

parent 23f4a9d2
......@@ -15,7 +15,7 @@ using std::endl;
int main() {
actor_system system;
for (int i = 1; i <= 50; ++i) {
system.spawn<blocking_api>([i](blocking_actor* self) {
system.spawn([i](blocking_actor* self) {
aout(self) << "Hi there! This is actor nr. "
<< i << "!" << endl;
std::random_device rd;
......
......@@ -92,8 +92,7 @@ int main() {
actor_system system;
scoped_actor self{system};
aout(self) << "blocking actor:" << endl;
self->spawn(tester<actor>,
self->spawn<blocking_api>(blocking_calculator), 1, 2);
self->spawn(tester<actor>, self->spawn(blocking_calculator), 1, 2);
self->await_all_other_actors_done();
aout(self) << "event-based actor:" << endl;
self->spawn(tester<actor>, self->spawn(calculator), 3, 4);
......
......@@ -272,13 +272,6 @@ public:
template <spawn_options Os, class C, class F, class... Ts>
infer_handle_from_class_t<C>
spawn_functor_impl(actor_config& cfg, F& fun, Ts&&... xs) {
constexpr bool is_blocking = std::is_base_of<blocking_actor, C>::value;
static_assert(is_blocking || ! has_blocking_api_flag(Os),
"blocking functor-based actors "
"need to be spawned using the blocking_api flag");
static_assert(! is_blocking || has_blocking_api_flag(Os),
"non-blocking functor-based actors "
"cannot be spawned using the blocking_api flag");
detail::init_fun_factory<C, F> fac;
cfg.init_fun = fac(std::move(fun), std::forward<Ts>(xs)...);
return spawn_impl<C, Os>(cfg);
......@@ -409,16 +402,12 @@ private:
template <class C, spawn_options Os, class... Ts>
infer_handle_from_class_t<C>
spawn_impl(actor_config& cfg, Ts&&... xs) {
static_assert(! std::is_base_of<blocking_actor, C>::value
|| has_blocking_api_flag(Os),
"C is derived from blocking_actor but "
"spawned without blocking_api_flag");
static_assert(is_unbound(Os),
"top-level spawns cannot have monitor or link flag");
cfg.flags = has_priority_aware_flag(Os)
? abstract_actor::is_priority_aware_flag
: 0;
if (has_detach_flag(Os) || has_blocking_api_flag(Os))
if (has_detach_flag(Os) || std::is_base_of<blocking_actor, C>::value)
cfg.flags |= abstract_actor::is_detached_flag;
if (! cfg.host)
cfg.host = dummy_execution_unit();
......
......@@ -33,8 +33,7 @@
namespace caf {
/// A cooperatively scheduled, event-based actor implementation. This is the
/// recommended base class for user-defined actors and is used implicitly when
/// spawning functor-based actors without the `blocking_api` flag.
/// recommended base class for user-defined actors.
/// @extends local_actor
class event_based_actor : public abstract_event_based_actor<behavior, true> {
public:
......
......@@ -35,7 +35,6 @@ enum class spawn_options : int {
monitor_flag = 0x02,
detach_flag = 0x04,
hide_flag = 0x08,
blocking_api_flag = 0x10,
priority_aware_flag = 0x20,
lazy_init_flag = 0x40
};
......@@ -66,11 +65,6 @@ constexpr spawn_options detached = spawn_options::detach_flag;
/// Causes the runtime to ignore the new actor in `await_all_actors_done()`.
constexpr spawn_options hidden = spawn_options::hide_flag;
/// Causes the new actor to opt in to the blocking API,
/// i.e., the actor uses a context-switching or thread-based backend
/// instead of the default event-based implementation.
constexpr spawn_options blocking_api = spawn_options::blocking_api_flag;
/// Causes the new actor to evaluate message priorities.
/// @note This implicitly causes the actor to run in its own thread.
constexpr spawn_options priority_aware = spawn_options::priority_aware_flag;
......@@ -115,12 +109,6 @@ constexpr bool has_monitor_flag(spawn_options opts) {
return has_spawn_option(opts, monitored);
}
/// Checks wheter the {@link blocking_api} flag is set in `opts`.
/// @relates spawn_options
constexpr bool has_blocking_api_flag(spawn_options opts) {
return has_spawn_option(opts, blocking_api);
}
/// Checks wheter the {@link lazy_init} flag is set in `opts`.
/// @relates spawn_options
constexpr bool has_lazy_init_flag(spawn_options opts) {
......
......@@ -31,10 +31,8 @@
namespace caf {
/// A cooperatively scheduled, event-based actor implementation with strong type
/// checking. This is the recommended base class for user-defined actors and is
/// used implicitly when spawning typed, functor-based actors without the
/// `blocking_api` flag.
/// A cooperatively scheduled, event-based actor
/// implementation with static type-checking.
/// @extends local_actor
template <class... Sigs>
class typed_event_based_actor
......
......@@ -321,8 +321,8 @@ void printer_loop(blocking_actor* self) {
void abstract_coordinator::start() {
CAF_LOG_TRACE("");
// launch utility actors
timer_ = system_.spawn<timer_actor, hidden + detached + blocking_api>();
printer_ = system_.spawn<hidden + detached + blocking_api>(printer_loop);
timer_ = system_.spawn<timer_actor, hidden + detached>();
printer_ = system_.spawn<hidden + detached>(printer_loop);
}
void abstract_coordinator::init(actor_system_config& cfg) {
......
......@@ -511,7 +511,7 @@ CAF_TEST(spawn_event_testee2_test) {
#ifndef CAF_WINDOWS
CAF_TEST(requests) {
scoped_actor self{system};
auto sync_testee = system.spawn<blocking_api>([](blocking_actor* s) {
auto sync_testee = system.spawn([](blocking_actor* s) {
s->receive (
on("hi", arg_match) >> [&](actor from) {
s->request(from, "whassup?", s).receive(
......
......@@ -302,7 +302,7 @@ CAF_TEST(pending_quit) {
CAF_TEST(request) {
scoped_actor self{system};
self->spawn<monitored + blocking_api>([](blocking_actor* s) {
self->spawn<monitored>([](blocking_actor* s) {
int invocations = 0;
auto foi = s->spawn<float_or_int, linked>();
s->send(foi, i_atom::value);
......@@ -464,7 +464,7 @@ CAF_TEST(request) {
self->await_all_other_actors_done();
CAF_MESSAGE("`await_all_other_actors_done` finished");
// test use case 3
self->spawn<monitored + blocking_api>([](blocking_actor* s) { // client
self->spawn<monitored>([](blocking_actor* s) { // client
auto serv = s->spawn<linked>(server); // server
auto work = s->spawn<linked>([]() -> behavior { // worker
return {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment