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
bb953534
Commit
bb953534
authored
Jul 09, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `policies` to `actor_policies`
parent
236a1fb2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
78 deletions
+92
-78
cppa/all.hpp
cppa/all.hpp
+0
-1
cppa/policy.hpp
cppa/policy.hpp
+0
-33
cppa/policy/actor_policies.hpp
cppa/policy/actor_policies.hpp
+23
-7
cppa/spawn.hpp
cppa/spawn.hpp
+41
-18
src/scheduler.cpp
src/scheduler.cpp
+18
-13
src/scoped_actor.cpp
src/scoped_actor.cpp
+10
-6
No files found.
cppa/all.hpp
View file @
bb953534
...
...
@@ -29,7 +29,6 @@
#include "cppa/spawn.hpp"
#include "cppa/config.hpp"
#include "cppa/extend.hpp"
#include "cppa/policy.hpp"
#include "cppa/channel.hpp"
#include "cppa/message.hpp"
#include "cppa/node_id.hpp"
...
...
cppa/policy.hpp
deleted
100644 → 0
View file @
236a1fb2
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the Boost Software License, Version 1.0. See *
* accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt *
\******************************************************************************/
#ifndef CPPA_POLICY_HPP
#define CPPA_POLICY_HPP
#include "cppa/policy/policies.hpp"
#include "cppa/policy/no_resume.hpp"
#include "cppa/policy/prioritizing.hpp"
#include "cppa/policy/no_scheduling.hpp"
#include "cppa/policy/invoke_policy.hpp"
#include "cppa/policy/nestable_invoke.hpp"
#include "cppa/policy/not_prioritizing.hpp"
#include "cppa/policy/sequential_invoke.hpp"
#include "cppa/policy/event_based_resume.hpp"
#include "cppa/policy/cooperative_scheduling.hpp"
#endif // CPPA_POLICY_HPP
cppa/policy/policies.hpp
→
cppa/policy/
actor_
policies.hpp
View file @
bb953534
...
...
@@ -22,24 +22,40 @@
namespace
cppa
{
namespace
policy
{
template
<
class
SchedulingPolicy
,
class
PriorityPolicy
,
class
ResumePolicy
,
class
InvokePolicy
>
class
policies
{
/**
* @brief A container for actor-related policies.
*/
template
<
class
SchedulingPolicy
,
class
PriorityPolicy
,
class
ResumePolicy
,
class
InvokePolicy
>
class
actor_policies
{
public:
using
scheduling_policy
=
SchedulingPolicy
;
using
priority_policy
=
PriorityPolicy
;
using
resume_policy
=
ResumePolicy
;
using
invoke_policy
=
InvokePolicy
;
scheduling_policy
&
get_scheduling_policy
()
{
return
m_scheduling_policy
;
}
inline
scheduling_policy
&
get_scheduling_policy
()
{
return
m_scheduling_policy
;
}
priority_policy
&
get_priority_policy
()
{
return
m_priority_policy
;
}
inline
priority_policy
&
get_priority_policy
()
{
return
m_priority_policy
;
}
resume_policy
&
get_resume_policy
()
{
return
m_resume_policy
;
}
inline
resume_policy
&
get_resume_policy
()
{
return
m_resume_policy
;
}
invoke_policy
&
get_invoke_policy
()
{
return
m_invoke_policy
;
}
inline
invoke_policy
&
get_invoke_policy
()
{
return
m_invoke_policy
;
}
private:
...
...
cppa/spawn.hpp
View file @
bb953534
...
...
@@ -21,13 +21,22 @@
#include <type_traits>
#include "cppa/policy.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/spawn_fwd.hpp"
#include "cppa/typed_actor.hpp"
#include "cppa/spawn_options.hpp"
#include "cppa/typed_event_based_actor.hpp"
#include "cppa/policy/no_resume.hpp"
#include "cppa/policy/prioritizing.hpp"
#include "cppa/policy/no_scheduling.hpp"
#include "cppa/policy/actor_policies.hpp"
#include "cppa/policy/nestable_invoke.hpp"
#include "cppa/policy/not_prioritizing.hpp"
#include "cppa/policy/sequential_invoke.hpp"
#include "cppa/policy/event_based_resume.hpp"
#include "cppa/policy/cooperative_scheduling.hpp"
#include "cppa/detail/logging.hpp"
#include "cppa/detail/type_traits.hpp"
#include "cppa/detail/make_counted.hpp"
...
...
@@ -46,30 +55,44 @@ class spawn_as_is {};
template
<
class
C
,
spawn_options
Os
,
typename
BeforeLaunch
,
typename
...
Ts
>
intrusive_ptr
<
C
>
spawn_impl
(
execution_unit
*
eu
,
BeforeLaunch
before_launch_fun
,
Ts
&&
...
args
)
{
static_assert
(
!
std
::
is_base_of
<
blocking_actor
,
C
>::
value
||
has_blocking_api_flag
(
Os
),
static_assert
(
!
std
::
is_base_of
<
blocking_actor
,
C
>::
value
||
has_blocking_api_flag
(
Os
),
"C is derived type of blocking_actor but "
"blocking_api_flag is missing"
);
static_assert
(
is_unbound
(
Os
),
"top-level spawns cannot have monitor or link flag"
);
CPPA_LOGF_TRACE
(
"spawn "
<<
detail
::
demangle
<
C
>
());
using
scheduling_policy
=
typename
std
::
conditional
<
has_detach_flag
(
Os
)
||
has_blocking_api_flag
(
Os
),
policy
::
no_scheduling
,
policy
::
cooperative_scheduling
>
::
type
;
using
scheduling_policy
=
typename
std
::
conditional
<
has_detach_flag
(
Os
)
||
has_blocking_api_flag
(
Os
),
policy
::
no_scheduling
,
policy
::
cooperative_scheduling
>::
type
;
using
priority_policy
=
typename
std
::
conditional
<
has_priority_aware_flag
(
Os
),
policy
::
prioritizing
,
policy
::
not_prioritizing
>::
type
;
using
resume_policy
=
typename
std
::
conditional
<
has_blocking_api_flag
(
Os
),
policy
::
no_resume
,
policy
::
event_based_resume
>::
type
;
has_priority_aware_flag
(
Os
),
policy
::
prioritizing
,
policy
::
not_prioritizing
>::
type
;
using
resume_policy
=
typename
std
::
conditional
<
has_blocking_api_flag
(
Os
),
policy
::
no_resume
,
policy
::
event_based_resume
>::
type
;
using
invoke_policy
=
typename
std
::
conditional
<
has_blocking_api_flag
(
Os
),
policy
::
nestable_invoke
,
policy
::
sequential_invoke
>::
type
;
using
policies
=
policy
::
policies
<
scheduling_policy
,
priority_policy
,
resume_policy
,
invoke_policy
>
;
using
actor_impl
=
typename
std
::
conditional
<
std
::
is_base_of
<
spawn_as_is
,
C
>::
value
,
C
,
detail
::
proper_actor
<
C
,
policies
>>::
type
;
has_blocking_api_flag
(
Os
),
policy
::
nestable_invoke
,
policy
::
sequential_invoke
>::
type
;
using
policy_token
=
policy
::
actor_policies
<
scheduling_policy
,
priority_policy
,
resume_policy
,
invoke_policy
>
;
using
actor_impl
=
typename
std
::
conditional
<
std
::
is_base_of
<
spawn_as_is
,
C
>::
value
,
C
,
detail
::
proper_actor
<
C
,
policy_token
>
>::
type
;
auto
ptr
=
detail
::
make_counted
<
actor_impl
>
(
std
::
forward
<
Ts
>
(
args
)...);
CPPA_LOGF_DEBUG
(
"spawned actor with ID "
<<
ptr
->
id
());
CPPA_PUSH_AID
(
ptr
->
id
());
...
...
src/scheduler.cpp
View file @
bb953534
...
...
@@ -23,7 +23,6 @@
#include <condition_variable>
#include "cppa/on.hpp"
#include "cppa/policy.hpp"
#include "cppa/anything.hpp"
#include "cppa/to_string.hpp"
#include "cppa/scheduler.hpp"
...
...
@@ -31,6 +30,12 @@
#include "cppa/scoped_actor.hpp"
#include "cppa/system_messages.hpp"
#include "cppa/policy/no_resume.hpp"
#include "cppa/policy/no_scheduling.hpp"
#include "cppa/policy/actor_policies.hpp"
#include "cppa/policy/nestable_invoke.hpp"
#include "cppa/policy/not_prioritizing.hpp"
#include "cppa/detail/logging.hpp"
#include "cppa/detail/proper_actor.hpp"
#include "cppa/detail/actor_registry.hpp"
...
...
@@ -48,16 +53,18 @@ using hrc = std::chrono::high_resolution_clock;
using
time_point
=
hrc
::
time_point
;
using
timer_actor_policies
=
policy
::
policies
<
policy
::
no_scheduling
,
policy
::
not_prioritizing
,
policy
::
no_resume
,
policy
::
nestable_invoke
>
;
using
timer_actor_policies
=
policy
::
actor_policies
<
policy
::
no_scheduling
,
policy
::
not_prioritizing
,
policy
::
no_resume
,
policy
::
nestable_invoke
>
;
struct
delayed_msg
{
actor_addr
from
;
channel
to
;
message_id
mid
;
message
msg
;
};
inline
void
deliver
(
delayed_msg
&
dm
)
{
...
...
@@ -72,8 +79,8 @@ inline void insert_dmsg(Map& storage, const duration& d, Ts&&... vs) {
storage
.
insert
(
std
::
make_pair
(
std
::
move
(
tout
),
std
::
move
(
dmsg
)));
}
class
timer_actor
final
:
public
detail
::
proper_actor
<
blocking_actor
,
timer_actor_policies
>
{
class
timer_actor
final
:
public
detail
::
proper_actor
<
blocking_actor
,
timer_actor_policies
>
{
public:
...
...
@@ -103,10 +110,10 @@ class timer_actor final
insert_dmsg
(
messages
,
d
,
std
::
move
(
from
),
std
::
move
(
to
),
mid
,
std
::
move
(
tup
));
},
on
(
atom
(
"DIE"
))
>>
[
&
]
{
done
=
true
;
},
others
()
>>
[
&
]
()
{
#ifdef CPPA_DEBUG_MODE
std
::
cerr
<<
"coordinator::timer_loop: UNKNOWN MESSAGE: "
<<
to_string
(
msg_ptr
->
msg
)
<<
std
::
endl
;
on
(
atom
(
"DIE"
))
>>
[
&
]
{
done
=
true
;
},
others
()
>>
[
&
]
{
#
ifdef CPPA_DEBUG_MODE
std
::
cerr
<<
"coordinator::timer_loop: UNKNOWN MESSAGE: "
<<
to_string
(
msg_ptr
->
msg
)
<<
std
::
endl
;
# endif
});
// loop
...
...
@@ -147,14 +154,12 @@ void printer_loop(blocking_actor* self) {
line
.
clear
();
}
}
};
auto
flush_if_needed
=
[](
std
::
string
&
str
)
{
if
(
str
.
back
()
==
'\n'
)
{
std
::
cout
<<
str
<<
std
::
flush
;
str
.
clear
();
}
};
bool
running
=
true
;
self
->
receive_while
([
&
]
{
return
running
;
})(
...
...
src/scoped_actor.cpp
View file @
bb953534
...
...
@@ -16,9 +16,14 @@
* accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt *
\******************************************************************************/
#include "cppa/policy.hpp"
#include "cppa/scoped_actor.hpp"
#include "cppa/policy/no_resume.hpp"
#include "cppa/policy/no_scheduling.hpp"
#include "cppa/policy/actor_policies.hpp"
#include "cppa/policy/nestable_invoke.hpp"
#include "cppa/policy/not_prioritizing.hpp"
#include "cppa/detail/singletons.hpp"
#include "cppa/detail/proper_actor.hpp"
#include "cppa/detail/actor_registry.hpp"
...
...
@@ -33,11 +38,10 @@ struct impl : blocking_actor {
blocking_actor
*
alloc
()
{
using
namespace
policy
;
return
new
detail
::
proper_actor
<
impl
,
policies
<
no_scheduling
,
not_prioritizing
,
no_resume
,
nestable_invoke
>>
;
return
new
detail
::
proper_actor
<
impl
,
actor_policies
<
no_scheduling
,
not_prioritizing
,
no_resume
,
nestable_invoke
>>
;
}
}
// namespace <anonymous>
...
...
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