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
4368dde2
Commit
4368dde2
authored
Aug 22, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed actor_proxy_cache to provide get_or_put member funciton as well as get
parent
608676f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
27 deletions
+36
-27
cppa/detail/actor_proxy_cache.hpp
cppa/detail/actor_proxy_cache.hpp
+8
-2
src/actor_proxy_cache.cpp
src/actor_proxy_cache.cpp
+21
-19
src/unicast_network.cpp
src/unicast_network.cpp
+3
-3
src/uniform_type_info.cpp
src/uniform_type_info.cpp
+4
-3
No files found.
cppa/detail/actor_proxy_cache.hpp
View file @
4368dde2
...
@@ -49,7 +49,13 @@ class actor_proxy_cache {
...
@@ -49,7 +49,13 @@ class actor_proxy_cache {
public:
public:
actor_proxy_ptr
get
(
actor_id
aid
,
std
::
uint32_t
process_id
,
// returns existing instance if available or crates a new one
actor_proxy_ptr
get_or_put
(
actor_id
aid
,
std
::
uint32_t
process_id
,
const
process_information
::
node_id_type
&
node_id
);
actor_proxy_ptr
get
(
actor_id
aid
,
std
::
uint32_t
process_id
,
const
process_information
::
node_id_type
&
node_id
);
const
process_information
::
node_id_type
&
node_id
);
// @returns true if pptr was successfully removed, false otherwise
// @returns true if pptr was successfully removed, false otherwise
...
@@ -89,7 +95,7 @@ class actor_proxy_cache {
...
@@ -89,7 +95,7 @@ class actor_proxy_cache {
util
::
shared_spinlock
m_lock
;
util
::
shared_spinlock
m_lock
;
std
::
map
<
key_tuple
,
actor_proxy_ptr
,
key_tuple_less
>
m_entries
;
std
::
map
<
key_tuple
,
actor_proxy_ptr
,
key_tuple_less
>
m_entries
;
actor_proxy_ptr
get_impl
(
const
key_tuple
&
key
);
actor_proxy_ptr
get_impl
(
const
key_tuple
&
key
,
bool
do_put
);
};
};
...
...
src/actor_proxy_cache.cpp
View file @
4368dde2
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "cppa/util/shared_lock_guard.hpp"
#include "cppa/util/shared_lock_guard.hpp"
#include "cppa/util/upgrade_lock_guard.hpp"
#include "cppa/util/upgrade_lock_guard.hpp"
#include "cppa/detail/middleman.hpp"
#include "cppa/detail/network_manager.hpp"
#include "cppa/detail/network_manager.hpp"
#include "cppa/detail/actor_proxy_cache.hpp"
#include "cppa/detail/actor_proxy_cache.hpp"
#include "cppa/detail/singleton_manager.hpp"
#include "cppa/detail/singleton_manager.hpp"
...
@@ -44,34 +45,27 @@
...
@@ -44,34 +45,27 @@
// thread_specific_ptr
// thread_specific_ptr
//#include <boost/thread/tss.hpp>
//#include <boost/thread/tss.hpp>
namespace
{
namespace
cppa
{
namespace
detail
{
//boost::thread_specific_ptr<cppa::detail::actor_proxy_cache> s_proxy_cache;
cppa
::
detail
::
actor_proxy_cache
s_proxy_cache
;
}
// namespace <anonmyous>
namespace
{
actor_proxy_cache
s_proxy_cache
;
}
namespace
cppa
{
namespace
detail
{
actor_proxy_cache
&
get_actor_proxy_cache
()
{
return
s_proxy_cache
;
}
actor_proxy_cache
&
get_actor_proxy_cache
()
{
actor_proxy_ptr
actor_proxy_cache
::
get_or_put
(
actor_id
aid
,
/*
std
::
uint32_t
process_id
,
if (s_proxy_cache.get() == nullptr) {
const
process_information
::
node_id_type
&
node_id
)
{
s_proxy_cache.reset(new actor_proxy_cache);
key_tuple
k
{
node_id
,
process_id
,
aid
};
}
return
get_impl
(
k
,
true
);
return *s_proxy_cache;
*/
return
s_proxy_cache
;
}
}
actor_proxy_ptr
actor_proxy_cache
::
get
(
actor_id
aid
,
actor_proxy_ptr
actor_proxy_cache
::
get
(
actor_id
aid
,
std
::
uint32_t
process_id
,
std
::
uint32_t
process_id
,
const
process_information
::
node_id_type
&
node_id
)
{
const
process_information
::
node_id_type
&
node_id
)
{
key_tuple
k
{
node_id
,
process_id
,
aid
};
key_tuple
k
{
node_id
,
process_id
,
aid
};
return
get_impl
(
k
);
return
get_impl
(
k
,
false
);
}
}
actor_proxy_ptr
actor_proxy_cache
::
get_impl
(
const
key_tuple
&
key
)
{
actor_proxy_ptr
actor_proxy_cache
::
get_impl
(
const
key_tuple
&
key
,
bool
do_put
)
{
{
// lifetime scope of shared guard
{
// lifetime scope of shared guard
util
::
shared_lock_guard
<
util
::
shared_spinlock
>
guard
{
m_lock
};
util
::
shared_lock_guard
<
util
::
shared_spinlock
>
guard
{
m_lock
};
auto
i
=
m_entries
.
find
(
key
);
auto
i
=
m_entries
.
find
(
key
);
...
@@ -79,7 +73,10 @@ actor_proxy_ptr actor_proxy_cache::get_impl(const key_tuple& key) {
...
@@ -79,7 +73,10 @@ actor_proxy_ptr actor_proxy_cache::get_impl(const key_tuple& key) {
return
i
->
second
;
return
i
->
second
;
}
}
}
}
actor_proxy_ptr
result
{
new
actor_proxy
(
std
::
get
<
2
>
(
key
),
new
process_information
(
std
::
get
<
1
>
(
key
),
std
::
get
<
0
>
(
key
)))};
if
(
!
do_put
)
{
return
nullptr
;
}
process_information_ptr
pip
(
new
process_information
(
std
::
get
<
1
>
(
key
),
std
::
get
<
0
>
(
key
)));
actor_proxy_ptr
result
(
new
actor_proxy
(
std
::
get
<
2
>
(
key
),
pip
));
{
// lifetime scope of exclusive guard
{
// lifetime scope of exclusive guard
std
::
lock_guard
<
util
::
shared_spinlock
>
guard
{
m_lock
};
std
::
lock_guard
<
util
::
shared_spinlock
>
guard
{
m_lock
};
auto
i
=
m_entries
.
find
(
key
);
auto
i
=
m_entries
.
find
(
key
);
...
@@ -91,7 +88,12 @@ actor_proxy_ptr actor_proxy_cache::get_impl(const key_tuple& key) {
...
@@ -91,7 +88,12 @@ actor_proxy_ptr actor_proxy_cache::get_impl(const key_tuple& key) {
result
->
attach_functor
([
result
](
std
::
uint32_t
)
{
result
->
attach_functor
([
result
](
std
::
uint32_t
)
{
get_actor_proxy_cache
().
erase
(
result
);
get_actor_proxy_cache
().
erase
(
result
);
});
});
result
->
enqueue
(
nullptr
,
make_any_tuple
(
atom
(
"MONITOR"
)));
middleman_enqueue
(
pip
,
nullptr
,
nullptr
,
make_any_tuple
(
atom
(
"MONITOR"
),
pip
,
std
::
get
<
2
>
(
key
)));
return
result
;
return
result
;
}
}
...
...
src/unicast_network.cpp
View file @
4368dde2
...
@@ -84,9 +84,9 @@ actor_ptr remote_actor(util::io_stream_ptr_pair peer) {
...
@@ -84,9 +84,9 @@ actor_ptr remote_actor(util::io_stream_ptr_pair peer) {
process_information_ptr
pinfptr
(
new
process_information
(
peer_pid
,
peer_node_id
));
process_information_ptr
pinfptr
(
new
process_information
(
peer_pid
,
peer_node_id
));
//auto key = std::make_tuple(remote_actor_id, pinfptr->process_id(), pinfptr->node_id());
//auto key = std::make_tuple(remote_actor_id, pinfptr->process_id(), pinfptr->node_id());
detail
::
middleman_add_peer
(
peer
,
pinfptr
);
detail
::
middleman_add_peer
(
peer
,
pinfptr
);
return
detail
::
get_actor_proxy_cache
().
get
(
remote_actor_id
,
return
detail
::
get_actor_proxy_cache
().
get
_or_put
(
remote_actor_id
,
pinfptr
->
process_id
(),
pinfptr
->
process_id
(),
pinfptr
->
node_id
());
pinfptr
->
node_id
());
}
}
void
publish
(
actor_ptr
whom
,
std
::
uint16_t
port
)
{
void
publish
(
actor_ptr
whom
,
std
::
uint16_t
port
)
{
...
...
src/uniform_type_info.cpp
View file @
4368dde2
...
@@ -232,9 +232,10 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr> {
...
@@ -232,9 +232,10 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr> {
*/
*/
process_information
::
node_id_type
nid
;
process_information
::
node_id_type
nid
;
node_id_from_string
(
nstr
,
nid
);
node_id_from_string
(
nstr
,
nid
);
ptrref
=
detail
::
get_actor_proxy_cache
().
get
(
get
<
std
::
uint32_t
>
(
ptup
[
0
]),
auto
&
cache
=
detail
::
get_actor_proxy_cache
();
get
<
std
::
uint32_t
>
(
ptup
[
1
]),
ptrref
=
cache
.
get_or_put
(
get
<
std
::
uint32_t
>
(
ptup
[
0
]),
nid
);
get
<
std
::
uint32_t
>
(
ptup
[
1
]),
nid
);
}
}
}
}
}
}
...
...
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