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
b36cae49
Commit
b36cae49
authored
Apr 21, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed threading issue
parent
ce955a9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
cppa/abstract_actor.hpp
cppa/abstract_actor.hpp
+27
-13
No files found.
cppa/abstract_actor.hpp
View file @
b36cae49
...
...
@@ -44,9 +44,10 @@
#include "cppa/local_actor.hpp"
#include "cppa/attachable.hpp"
#include "cppa/exit_reason.hpp"
#include "cppa/util/shared_spinlock.hpp"
#include "cppa/detail/thread.hpp"
#include "cppa/detail/recursive_queue_node.hpp"
#include "cppa/intrusive/single_reader_queue.hpp"
namespace
cppa
{
...
...
@@ -167,35 +168,48 @@ class abstract_actor : public Base
mailbox_type
m_mailbox
;
util
::
fixed_vector
<
mailbox_element
*
,
10
>
m_nodes
;
util
::
shared_spinlock
m_nodes_lock
;
typedef
detail
::
lock_guard
<
util
::
shared_spinlock
>
lock_type
;
inline
mailbox_element
*
fetch_node
(
actor
*
sender
,
any_tuple
msg
)
{
if
(
m_nodes
.
empty
())
mailbox_element
*
result
=
nullptr
;
// lifetime scope of guard
{
return
new
mailbox_element
(
sender
,
std
::
move
(
msg
));
lock_type
guard
{
m_nodes_lock
};
if
(
m_nodes
.
not_empty
())
{
result
=
m_nodes
.
back
();
m_nodes
.
pop_back
();
}
}
else
if
(
result
)
{
mailbox_element
*
result
=
m_nodes
.
back
();
m_nodes
.
pop_back
();
result
->
next
=
nullptr
;
result
->
marked
=
false
;
result
->
sender
=
sender
;
result
->
msg
=
std
::
move
(
msg
);
return
result
;
}
else
{
result
=
new
mailbox_element
(
sender
,
std
::
move
(
msg
));
}
return
result
;
}
inline
void
release_node
(
mailbox_element
*
node
)
{
if
(
m_nodes
.
full
())
{
delete
node
;
}
else
// lifetime scope of guard
{
m_nodes
.
push_back
(
node
);
lock_type
guard
{
m_nodes_lock
};
if
(
m_nodes
.
full
()
==
false
)
{
m_nodes
.
push_back
(
node
);
return
;
}
}
delete
node
;
}
template
<
typename
...
Args
>
...
...
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