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
3dc9ed81
Commit
3dc9ed81
authored
Apr 30, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port examples to the new error API
parent
59d42ce0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
47 deletions
+30
-47
examples/message_passing/divider.cpp
examples/message_passing/divider.cpp
+6
-17
examples/message_passing/fixed_stack.cpp
examples/message_passing/fixed_stack.cpp
+9
-14
libcaf_core/caf/exit_reason.hpp
libcaf_core/caf/exit_reason.hpp
+3
-6
libcaf_core/caf/is_error_code_enum.hpp
libcaf_core/caf/is_error_code_enum.hpp
+8
-0
libcaf_core/caf/pec.hpp
libcaf_core/caf/pec.hpp
+2
-5
libcaf_core/caf/sec.hpp
libcaf_core/caf/sec.hpp
+2
-5
No files found.
examples/message_passing/divider.cpp
View file @
3dc9ed81
...
@@ -27,24 +27,13 @@ std::string to_string(math_error x) {
...
@@ -27,24 +27,13 @@ std::string to_string(math_error x) {
}
}
}
}
namespace
caf
{
CAF_BEGIN_TYPE_ID_BLOCK
(
divider
,
first_custom_type_id
)
template
<
>
CAF_ADD_TYPE_ID
(
divider
,
(
math_error
))
struct
error_category
<
math_error
>
{
static
constexpr
uint8_t
value
=
101
;
};
}
// namespace caf
CAF_END_TYPE_ID_BLOCK
(
divider
)
class
config
:
public
actor_system_config
{
CAF_ERROR_CODE_ENUM
(
math_error
)
public:
config
()
{
auto
renderer
=
[](
uint8_t
x
,
const
message
&
)
{
return
to_string
(
static_cast
<
math_error
>
(
x
));
};
add_error_category
(
caf
::
error_category
<
math_error
>::
value
,
renderer
);
}
};
using
divider
=
typed_actor
<
result
<
double
>
(
div_atom
,
double
,
double
)
>
;
using
divider
=
typed_actor
<
result
<
double
>
(
div_atom
,
double
,
double
)
>
;
...
@@ -58,7 +47,7 @@ divider::behavior_type divider_impl() {
...
@@ -58,7 +47,7 @@ divider::behavior_type divider_impl() {
};
};
}
}
void
caf_main
(
actor_system
&
system
,
const
config
&
)
{
void
caf_main
(
actor_system
&
system
)
{
double
x
;
double
x
;
double
y
;
double
y
;
cout
<<
"x: "
<<
flush
;
cout
<<
"x: "
<<
flush
;
...
@@ -76,4 +65,4 @@ void caf_main(actor_system& system, const config&) {
...
@@ -76,4 +65,4 @@ void caf_main(actor_system& system, const config&) {
});
});
}
}
CAF_MAIN
()
CAF_MAIN
(
id_block
::
divider
)
examples/message_passing/fixed_stack.cpp
View file @
3dc9ed81
...
@@ -3,30 +3,25 @@
...
@@ -3,30 +3,25 @@
#include <cstdint>
#include <cstdint>
#include <iostream>
#include <iostream>
enum
class
fixed_stack_errc
:
uint8_t
{
push_to_full
=
1
,
pop_from_empty
,
};
CAF_BEGIN_TYPE_ID_BLOCK
(
fixed_stack
,
first_custom_type_id
)
CAF_BEGIN_TYPE_ID_BLOCK
(
fixed_stack
,
first_custom_type_id
)
CAF_ADD_TYPE_ID
(
fixed_stack
,
(
fixed_stack_errc
))
CAF_ADD_ATOM
(
fixed_stack
,
pop_atom
)
CAF_ADD_ATOM
(
fixed_stack
,
pop_atom
)
CAF_ADD_ATOM
(
fixed_stack
,
push_atom
)
CAF_ADD_ATOM
(
fixed_stack
,
push_atom
)
CAF_END_TYPE_ID_BLOCK
(
fixed_stack
)
CAF_END_TYPE_ID_BLOCK
(
fixed_stack
)
CAF_ERROR_CODE_ENUM
(
fixed_stack_errc
)
using
std
::
endl
;
using
std
::
endl
;
using
namespace
caf
;
using
namespace
caf
;
enum
class
fixed_stack_errc
:
uint8_t
{
push_to_full
=
1
,
pop_from_empty
,
};
namespace
caf
{
template
<
>
struct
error_category
<
fixed_stack_errc
>
{
static
constexpr
uint8_t
value
=
100
;
};
}
// namespace caf
class
fixed_stack
:
public
event_based_actor
{
class
fixed_stack
:
public
event_based_actor
{
public:
public:
fixed_stack
(
actor_config
&
cfg
,
size_t
stack_size
)
fixed_stack
(
actor_config
&
cfg
,
size_t
stack_size
)
...
...
libcaf_core/caf/exit_reason.hpp
View file @
3dc9ed81
...
@@ -52,12 +52,9 @@ enum class exit_reason : uint8_t {
...
@@ -52,12 +52,9 @@ enum class exit_reason : uint8_t {
unreachable
unreachable
};
};
///
Returns a string representation of given exit reason.
///
@relates exit_reason
CAF_CORE_EXPORT
std
::
string
to_string
(
exit_reason
);
CAF_CORE_EXPORT
std
::
string
to_string
(
exit_reason
);
template
<
>
struct
is_error_code_enum
<
exit_reason
>
{
static
constexpr
bool
value
=
true
;
};
}
// namespace caf
}
// namespace caf
CAF_ERROR_CODE_ENUM
(
exit_reason
)
libcaf_core/caf/is_error_code_enum.hpp
View file @
3dc9ed81
...
@@ -32,3 +32,11 @@ template <class T>
...
@@ -32,3 +32,11 @@ template <class T>
constexpr
bool
is_error_code_enum_v
=
is_error_code_enum
<
T
>::
value
;
constexpr
bool
is_error_code_enum_v
=
is_error_code_enum
<
T
>::
value
;
}
// namespace caf
}
// namespace caf
#define CAF_ERROR_CODE_ENUM(type_name) \
namespace caf { \
template <> \
struct is_error_code_enum<type_name> { \
static constexpr bool value = true; \
}; \
}
libcaf_core/caf/pec.hpp
View file @
3dc9ed81
...
@@ -79,9 +79,6 @@ enum class pec : uint8_t {
...
@@ -79,9 +79,6 @@ enum class pec : uint8_t {
CAF_CORE_EXPORT
std
::
string
to_string
(
pec
);
CAF_CORE_EXPORT
std
::
string
to_string
(
pec
);
template
<
>
struct
is_error_code_enum
<
pec
>
{
static
constexpr
bool
value
=
true
;
};
}
// namespace caf
}
// namespace caf
CAF_ERROR_CODE_ENUM
(
pec
)
libcaf_core/caf/sec.hpp
View file @
3dc9ed81
...
@@ -150,9 +150,6 @@ enum class sec : uint8_t {
...
@@ -150,9 +150,6 @@ enum class sec : uint8_t {
/// @relates sec
/// @relates sec
CAF_CORE_EXPORT
std
::
string
to_string
(
sec
);
CAF_CORE_EXPORT
std
::
string
to_string
(
sec
);
template
<
>
struct
is_error_code_enum
<
sec
>
{
static
constexpr
bool
value
=
true
;
};
}
// namespace caf
}
// namespace caf
CAF_ERROR_CODE_ENUM
(
sec
)
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