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
ec8ba04f
Commit
ec8ba04f
authored
Mar 07, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Terminate actor pool when out of workers
parent
770a1e8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
libcaf_core/caf/actor_pool.hpp
libcaf_core/caf/actor_pool.hpp
+4
-1
libcaf_core/caf/exit_reason.hpp
libcaf_core/caf/exit_reason.hpp
+5
-0
libcaf_core/src/actor_pool.cpp
libcaf_core/src/actor_pool.cpp
+14
-5
No files found.
libcaf_core/caf/actor_pool.hpp
View file @
ec8ba04f
...
...
@@ -119,12 +119,15 @@ class actor_pool : public abstract_actor {
void
enqueue
(
mailbox_element_ptr
what
,
execution_unit
*
host
)
override
;
private:
actor_pool
();
private:
bool
filter
(
upgrade_lock
<
detail
::
shared_spinlock
>&
,
const
actor_addr
&
sender
,
message_id
mid
,
const
message
&
content
,
execution_unit
*
host
);
// call without m_mtx held
void
quit
();
detail
::
shared_spinlock
m_mtx
;
std
::
vector
<
actor
>
m_workers
;
policy
m_policy
;
...
...
libcaf_core/caf/exit_reason.hpp
View file @
ec8ba04f
...
...
@@ -56,6 +56,11 @@ static constexpr uint32_t unhandled_sync_timeout = 0x00005;
*/
static
constexpr
uint32_t
unknown
=
0x00006
;
/**
* Indicates that an actor pool unexpectedly ran out of workers.
*/
static
constexpr
uint32_t
out_of_workers
=
0x00007
;
/**
* Indicates that the actor was forced to shutdown by a user-generated event.
*/
...
...
libcaf_core/src/actor_pool.cpp
View file @
ec8ba04f
...
...
@@ -77,7 +77,7 @@ actor_pool::~actor_pool() {
actor
actor_pool
::
make
(
policy
pol
)
{
intrusive_ptr
<
actor_pool
>
ptr
;
ptr
.
reset
(
new
actor_pool
);
ptr
=
make_counted
<
actor_pool
>
(
);
ptr
->
m_policy
=
std
::
move
(
pol
);
return
actor_cast
<
actor
>
(
ptr
);
}
...
...
@@ -139,10 +139,7 @@ bool actor_pool::filter(upgrade_lock<detail::shared_spinlock>& guard,
for
(
auto
&
w
:
workers
)
{
anon_send
(
w
,
msg
);
}
// we can safely run our cleanup code here
// because abstract_actor has its own lock
cleanup
(
m_planned_reason
);
is_registered
(
false
);
quit
();
return
true
;
}
if
(
msg
.
match_elements
<
down_msg
>
())
{
...
...
@@ -154,6 +151,11 @@ bool actor_pool::filter(upgrade_lock<detail::shared_spinlock>& guard,
if
(
i
!=
last
)
{
m_workers
.
erase
(
i
);
}
if
(
m_workers
.
empty
())
{
m_planned_reason
=
exit_reason
::
out_of_workers
;
unique_guard
.
unlock
();
quit
();
}
return
true
;
}
if
(
msg
.
match_elements
<
sys_atom
,
put_atom
,
actor
>
())
{
...
...
@@ -198,4 +200,11 @@ bool actor_pool::filter(upgrade_lock<detail::shared_spinlock>& guard,
return
false
;
}
void
actor_pool
::
quit
()
{
// we can safely run our cleanup code here without holding
// m_mtx because abstract_actor has its own lock
cleanup
(
m_planned_reason
);
is_registered
(
false
);
}
}
// namespace caf
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