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
5ac2c932
Commit
5ac2c932
authored
Jun 30, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix build with CAF_NO_EXCEPTIONS enabled
parent
f67e6a11
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
68 deletions
+19
-68
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+9
-8
libcaf_core/test/custom_exception_handler.cpp
libcaf_core/test/custom_exception_handler.cpp
+10
-0
libcaf_core/test/dynamic_spawn.cpp
libcaf_core/test/dynamic_spawn.cpp
+0
-60
No files found.
libcaf_core/src/scheduled_actor.cpp
View file @
5ac2c932
...
...
@@ -19,6 +19,7 @@
#include "caf/scheduled_actor.hpp"
#include "caf/config.hpp"
#include "caf/actor_ostream.hpp"
#include "caf/detail/private_thread.hpp"
...
...
@@ -481,9 +482,9 @@ bool scheduled_actor::activate(execution_unit* ctx) {
"resume called on a terminated actor"
);
return
false
;
}
# ifndef CAF_NO_EXCEPTION
# ifndef CAF_NO_EXCEPTION
S
try
{
# endif // CAF_NO_EXCEPTION
# endif // CAF_NO_EXCEPTION
S
if
(
!
is_initialized
())
{
initialize
();
if
(
finalize
())
{
...
...
@@ -493,7 +494,7 @@ bool scheduled_actor::activate(execution_unit* ctx) {
CAF_LOG_DEBUG
(
"initialized actor:"
<<
CAF_ARG
(
name
()));
}
}
# ifndef CAF_NO_EXCEPTION
# ifndef CAF_NO_EXCEPTION
S
}
catch
(...)
{
CAF_LOG_ERROR
(
"actor died during initialization"
);
...
...
@@ -502,7 +503,7 @@ bool scheduled_actor::activate(execution_unit* ctx) {
finalize
();
return
false
;
}
# endif // CAF_NO_EXCEPTION
# endif // CAF_NO_EXCEPTION
S
return
true
;
}
...
...
@@ -516,9 +517,9 @@ auto scheduled_actor::activate(execution_unit* ctx, mailbox_element& x)
auto
scheduled_actor
::
reactivate
(
mailbox_element
&
x
)
->
activation_result
{
CAF_LOG_TRACE
(
CAF_ARG
(
x
));
# ifndef CAF_NO_EXCEPTION
# ifndef CAF_NO_EXCEPTION
S
try
{
# endif // CAF_NO_EXCEPTION
# endif // CAF_NO_EXCEPTION
S
switch
(
consume
(
x
))
{
case
im_dropped
:
return
activation_result
::
dropped
;
...
...
@@ -532,7 +533,7 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result {
case
im_skipped
:
return
activation_result
::
skipped
;
}
# ifndef CAF_NO_EXCEPTION
# ifndef CAF_NO_EXCEPTION
S
}
catch
(
std
::
exception
&
e
)
{
CAF_LOG_INFO
(
"actor died because of an exception, what: "
<<
e
.
what
());
...
...
@@ -547,7 +548,7 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result {
}
finalize
();
return
activation_result
::
terminated
;
# endif // CAF_NO_EXCEPTION
# endif // CAF_NO_EXCEPTION
S
}
// -- behavior management ----------------------------------------------------
...
...
libcaf_core/test/custom_exception_handler.cpp
View file @
5ac2c932
...
...
@@ -26,6 +26,8 @@
using
namespace
caf
;
#ifndef CAF_NO_EXCEPTIONS
class
exception_testee
:
public
event_based_actor
{
public:
~
exception_testee
();
...
...
@@ -77,3 +79,11 @@ CAF_TEST(test_custom_exception_handler) {
// receive all down messages
self
->
wait_for
(
testee1
,
testee2
,
testee3
);
}
#else // CAF_NO_EXCEPTIONS
CAF_TEST
(
no_exceptions_dummy
)
{
CAF_CHECK_EQUAL
(
true
,
true
);
}
#endif // CAF_NO_EXCEPTIONS
libcaf_core/test/dynamic_spawn.cpp
View file @
5ac2c932
...
...
@@ -559,66 +559,6 @@ CAF_TEST(constructor_attach) {
anon_send_exit
(
system
.
spawn
<
spawner
>
(),
exit_reason
::
user_shutdown
);
}
namespace
{
class
exception_testee
:
public
event_based_actor
{
public:
exception_testee
(
actor_config
&
cfg
)
:
event_based_actor
(
cfg
)
{
set_exception_handler
([](
std
::
exception_ptr
&
)
->
exit_reason
{
return
exit_reason
::
unhandled_exception
;
});
}
behavior
make_behavior
()
override
{
return
{
[](
const
std
::
string
&
str
)
{
throw
std
::
runtime_error
(
str
);
}
};
}
};
}
// namespace <anonymous>
CAF_TEST
(
custom_exception_handler
)
{
auto
handler
=
[](
std
::
exception_ptr
&
eptr
)
->
error
{
try
{
std
::
rethrow_exception
(
eptr
);
}
catch
(
std
::
runtime_error
&
)
{
return
exit_reason
::
unhandled_exception
;
}
catch
(...)
{
// "fall through"
}
return
exit_reason
::
unknown
;
};
scoped_actor
self
{
system
};
auto
testee1
=
self
->
spawn
<
monitored
>
([
=
](
event_based_actor
*
eb_self
)
{
eb_self
->
set_exception_handler
(
handler
);
throw
std
::
runtime_error
(
"ping"
);
});
auto
testee2
=
self
->
spawn
<
monitored
>
([
=
](
event_based_actor
*
eb_self
)
{
eb_self
->
set_exception_handler
(
handler
);
throw
std
::
logic_error
(
"pong"
);
});
auto
testee3
=
self
->
spawn
<
exception_testee
,
monitored
>
();
self
->
send
(
testee3
,
"foo"
);
// receive all down messages
int
downs_received
=
0
;
self
->
receive_for
(
downs_received
,
3
)
(
[
&
](
down_msg
&
dm
)
{
if
(
dm
.
source
==
testee1
)
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
unhandled_exception
);
else
if
(
dm
.
source
==
testee2
)
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
unknown
);
else
if
(
dm
.
source
==
testee3
)
CAF_CHECK_EQUAL
(
dm
.
reason
,
exit_reason
::
unhandled_exception
);
else
throw
std
::
runtime_error
(
"received message from unexpected source"
);
}
);
}
CAF_TEST
(
kill_the_immortal
)
{
auto
wannabe_immortal
=
system
.
spawn
([](
event_based_actor
*
self
)
->
behavior
{
self
->
set_exit_handler
([](
local_actor
*
,
exit_msg
&
)
{
...
...
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