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
f4912f83
Commit
f4912f83
authored
Dec 20, 2011
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some refactoring
parent
791bf4c3
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
24 deletions
+43
-24
cppa/abstract_actor.hpp
cppa/abstract_actor.hpp
+2
-2
cppa/actor.hpp
cppa/actor.hpp
+1
-1
cppa/attachable.hpp
cppa/attachable.hpp
+1
-1
cppa/group.hpp
cppa/group.hpp
+1
-1
cppa/self.hpp
cppa/self.hpp
+25
-15
src/cppa.cpp
src/cppa.cpp
+1
-1
src/group.cpp
src/group.cpp
+1
-1
src/scheduler.cpp
src/scheduler.cpp
+1
-1
src/self.cpp
src/self.cpp
+1
-1
unit_testing/test__spawn.cpp
unit_testing/test__spawn.cpp
+9
-0
No files found.
cppa/abstract_actor.hpp
View file @
f4912f83
...
@@ -138,7 +138,7 @@ class abstract_actor : public Base
...
@@ -138,7 +138,7 @@ class abstract_actor : public Base
}
}
for
(
attachable_ptr
&
ptr
:
mattachables
)
for
(
attachable_ptr
&
ptr
:
mattachables
)
{
{
ptr
->
detach
(
reason
);
ptr
->
actor_exited
(
reason
);
}
}
}
}
...
@@ -186,7 +186,7 @@ class abstract_actor : public Base
...
@@ -186,7 +186,7 @@ class abstract_actor : public Base
return
true
;
return
true
;
}
}
}
}
uptr
->
detach
(
reason
);
uptr
->
actor_exited
(
reason
);
return
false
;
return
false
;
}
}
}
}
...
...
cppa/actor.hpp
View file @
f4912f83
...
@@ -225,7 +225,7 @@ class functor_attachable : public attachable
...
@@ -225,7 +225,7 @@ class functor_attachable : public attachable
{
{
}
}
void
detach
(
std
::
uint32_t
reason
)
void
actor_exited
(
std
::
uint32_t
reason
)
{
{
m_functor
(
reason
);
m_functor
(
reason
);
}
}
...
...
cppa/attachable.hpp
View file @
f4912f83
...
@@ -39,7 +39,7 @@ class attachable
...
@@ -39,7 +39,7 @@ class attachable
*
*
* The default implementation does nothing.
* The default implementation does nothing.
*/
*/
virtual
void
detach
(
std
::
uint32_t
reason
)
=
0
;
virtual
void
actor_exited
(
std
::
uint32_t
reason
)
=
0
;
virtual
bool
matches
(
const
token
&
)
=
0
;
virtual
bool
matches
(
const
token
&
)
=
0
;
...
...
cppa/group.hpp
View file @
f4912f83
...
@@ -53,7 +53,7 @@ class group : public channel
...
@@ -53,7 +53,7 @@ class group : public channel
~
unsubscriber
();
~
unsubscriber
();
void
detach
(
std
::
uint32_t
);
void
actor_exited
(
std
::
uint32_t
);
// matches on m_group
// matches on m_group
bool
matches
(
const
attachable
::
token
&
what
);
bool
matches
(
const
attachable
::
token
&
what
);
...
...
cppa/self.hpp
View file @
f4912f83
...
@@ -7,6 +7,17 @@
...
@@ -7,6 +7,17 @@
namespace
cppa
{
namespace
cppa
{
#ifdef CPPA_DOCUMENTATION
/**
* @brief Always points to the current actor. Similar to @c this in
* an object-oriented context.
*/
extern
local_actor
*
self
;
#else
// convertible<...> enables "actor_ptr this_actor = self;"
class
self_type
:
public
convertible
<
self_type
,
actor
*>
class
self_type
:
public
convertible
<
self_type
,
actor
*>
{
{
...
@@ -16,21 +27,26 @@ class self_type : public convertible<self_type, actor*>
...
@@ -16,21 +27,26 @@ class self_type : public convertible<self_type, actor*>
static
local_actor
*
get_impl
();
static
local_actor
*
get_impl
();
self_type
(
const
self_type
&
)
=
delete
;
self_type
&
operator
=
(
const
self_type
&
)
=
delete
;
public:
public:
constexpr
self_type
()
{
}
// "inherited" from convertible<...>
inline
local_actor
*
do_convert
()
const
inline
local_actor
*
do_convert
()
const
{
{
return
get_impl
();
return
get_impl
();
}
}
constexpr
self_type
()
{
}
// allow "self" wherever an local_actor or actor pointer is expected
inline
operator
local_actor
*
()
const
inline
operator
local_actor
*
()
const
{
{
return
get_impl
();
return
get_impl
();
}
}
inline
local_actor
*
operator
->
()
inline
local_actor
*
operator
->
()
const
{
{
return
get_impl
();
return
get_impl
();
}
}
...
@@ -42,31 +58,25 @@ class self_type : public convertible<self_type, actor*>
...
@@ -42,31 +58,25 @@ class self_type : public convertible<self_type, actor*>
}
}
// @pre get_unchecked() == nullptr
// @pre get_unchecked() == nullptr
inline
void
set
(
local_actor
*
ptr
)
inline
void
set
(
local_actor
*
ptr
)
const
{
{
set_impl
(
ptr
);
set_impl
(
ptr
);
}
}
// @returns The current value without converting the calling context
// @returns The current value without converting the calling context
// to an actor on-the-fly.
// to an actor on-the-fly.
inline
local_actor
*
unchecked
()
inline
local_actor
*
unchecked
()
const
{
{
return
get_unchecked_impl
();
return
get_unchecked_impl
();
}
}
};
};
#ifdef CPPA_DOCUMENTATION
/*
* "self" emulates a new keyword. The object itself is useless, all it does
/**
* is to provide syntactic sugar like "self->trap_exit(true)".
* @brief Always points to the current actor. Similar to @c this in
* an object-oriented context.
*/
*/
extern
local_actor
*
self
;
constexpr
self_type
self
;
#else
extern
self_type
self
;
#endif
#endif
...
...
src/cppa.cpp
View file @
f4912f83
...
@@ -12,7 +12,7 @@ class observer : public cppa::attachable
...
@@ -12,7 +12,7 @@ class observer : public cppa::attachable
observer
(
cppa
::
actor_ptr
&&
client
)
:
m_client
(
std
::
move
(
client
))
{
}
observer
(
cppa
::
actor_ptr
&&
client
)
:
m_client
(
std
::
move
(
client
))
{
}
void
detach
(
std
::
uint32_t
reason
)
void
actor_exited
(
std
::
uint32_t
reason
)
{
{
using
namespace
cppa
;
using
namespace
cppa
;
send
(
m_client
,
atom
(
":Down"
),
actor_ptr
(
self
),
reason
);
send
(
m_client
,
atom
(
":Down"
),
actor_ptr
(
self
),
reason
);
...
...
src/group.cpp
View file @
f4912f83
...
@@ -30,7 +30,7 @@ group::unsubscriber::~unsubscriber()
...
@@ -30,7 +30,7 @@ group::unsubscriber::~unsubscriber()
if
(
m_group
&&
m_self
)
m_group
->
unsubscribe
(
m_self
);
if
(
m_group
&&
m_self
)
m_group
->
unsubscribe
(
m_self
);
}
}
void
group
::
unsubscriber
::
detach
(
std
::
uint32_t
)
void
group
::
unsubscriber
::
actor_exited
(
std
::
uint32_t
)
{
{
// unsubscription is done in destructor
// unsubscription is done in destructor
}
}
...
...
src/scheduler.cpp
View file @
f4912f83
...
@@ -25,7 +25,7 @@ struct exit_observer : cppa::attachable
...
@@ -25,7 +25,7 @@ struct exit_observer : cppa::attachable
{
{
cppa
::
detail
::
dec_actor_count
();
cppa
::
detail
::
dec_actor_count
();
}
}
void
detach
(
std
::
uint32_t
)
void
actor_exited
(
std
::
uint32_t
)
{
{
}
}
bool
matches
(
const
token
&
)
bool
matches
(
const
token
&
)
...
...
src/self.cpp
View file @
f4912f83
...
@@ -29,7 +29,7 @@ boost::thread_specific_ptr<cppa::local_actor> t_this_context(cleanup_fun);
...
@@ -29,7 +29,7 @@ boost::thread_specific_ptr<cppa::local_actor> t_this_context(cleanup_fun);
namespace
cppa
{
namespace
cppa
{
self_type
self
;
//
self_type self;
void
self_type
::
set_impl
(
local_actor
*
ptr
)
void
self_type
::
set_impl
(
local_actor
*
ptr
)
{
{
...
...
unit_testing/test__spawn.cpp
View file @
f4912f83
...
@@ -307,6 +307,15 @@ size_t test__spawn()
...
@@ -307,6 +307,15 @@ size_t test__spawn()
CPPA_CHECK_EQUAL
(
behavior_test
<
testee_actor
>
(),
"init_state"
);
CPPA_CHECK_EQUAL
(
behavior_test
<
testee_actor
>
(),
"init_state"
);
CPPA_CHECK_EQUAL
(
behavior_test
<
event_testee
>
(),
"init_state"
);
CPPA_CHECK_EQUAL
(
behavior_test
<
event_testee
>
(),
"init_state"
);
// create one million actors linked to one single actor
// and kill them all through killing the link
auto
my_link
=
spawn
(
new
event_testee
);
for
(
int
i
=
0
;
i
<
20000
;
++
i
)
{
link
(
my_link
,
spawn
(
new
event_testee
));
}
send
(
my_link
,
atom
(
":Exit"
),
exit_reason
::
user_defined
);
return
CPPA_TEST_RESULT
;
return
CPPA_TEST_RESULT
;
...
...
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