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
4a6eefe0
Commit
4a6eefe0
authored
Jun 12, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
makred cppa types as builtin
parent
e540b210
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
21 deletions
+105
-21
cppa/detail/addressed_message.hpp
cppa/detail/addressed_message.hpp
+2
-1
cppa/detail/types_array.hpp
cppa/detail/types_array.hpp
+5
-0
cppa/util/is_builtin.hpp
cppa/util/is_builtin.hpp
+42
-3
unit_testing/ping_pong.cpp
unit_testing/ping_pong.cpp
+12
-16
unit_testing/test__uniform_type.cpp
unit_testing/test__uniform_type.cpp
+44
-1
No files found.
cppa/detail/addressed_message.hpp
View file @
4a6eefe0
...
...
@@ -32,9 +32,10 @@
#define ADDRESSED_MESSAGE_HPP
#include "cppa/actor.hpp"
#include "cppa/cow_tuple.hpp"
#include "cppa/channel.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/cow_tuple.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/ref_counted.hpp"
#include "cppa/intrusive_ptr.hpp"
...
...
cppa/detail/types_array.hpp
View file @
4a6eefe0
...
...
@@ -49,10 +49,14 @@ struct ta_util<cppa_tinf, false, T> {
static
inline
const
uniform_type_info
*
get
()
{
return
nullptr
;
}
};
// only built-in types are guaranteed to be available at static initialization
// time, other types are announced at runtime
// implements types_array
template
<
bool
BuiltinOnlyTypes
,
typename
...
T
>
struct
types_array_impl
{
static
constexpr
bool
builtin_only
=
true
;
inline
bool
is_pure
()
const
{
return
true
;
}
// all types are builtin, perform lookup on constuction
const
uniform_type_info
*
data
[
sizeof
...(
T
)];
types_array_impl
()
:
data
{
ta_util
<
cppa_tinf
,
true
,
T
>::
get
()...}
{
}
...
...
@@ -67,6 +71,7 @@ struct types_array_impl {
template
<
typename
...
T
>
struct
types_array_impl
<
false
,
T
...
>
{
static
constexpr
bool
builtin_only
=
false
;
inline
bool
is_pure
()
const
{
return
false
;
}
// contains std::type_info for all non-builtin types
const
std
::
type_info
*
tinfo_data
[
sizeof
...(
T
)];
// contains uniform_type_infos for builtin types and lazy initializes
...
...
cppa/util/is_builtin.hpp
View file @
4a6eefe0
#ifndef IS_BUILTIN_HPP
#define IS_BUILTIN_HPP
#include <string>
#include <type_traits>
#include "cppa/atom.hpp"
#include "cppa/actor.hpp"
#include "cppa/group.hpp"
#include "cppa/channel.hpp"
#include "cppa/anything.hpp"
#include "cppa/intrusive_ptr.hpp"
#include "cppa/process_information.hpp"
namespace
cppa
{
class
any_tuple
;
}
namespace
cppa
{
namespace
detail
{
class
addressed_message
;
}
}
namespace
cppa
{
namespace
util
{
...
...
@@ -12,9 +23,37 @@ struct is_builtin {
};
template
<
>
struct
is_builtin
<
anything
>
{
static
constexpr
bool
value
=
true
;
};
struct
is_builtin
<
anything
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
std
::
string
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
std
::
u16string
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
std
::
u32string
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
atom_value
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
any_tuple
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
detail
::
addressed_message
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
actor_ptr
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
group_ptr
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
channel_ptr
>
:
std
::
true_type
{
};
template
<
>
struct
is_builtin
<
intrusive_ptr
<
process_information
>
>
:
std
::
true_type
{
};
}
}
// namespace cppa::util
...
...
unit_testing/ping_pong.cpp
View file @
4a6eefe0
...
...
@@ -29,8 +29,10 @@ void ping(size_t num_pings) {
}
},
others
()
>>
[]()
{
cout
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
cout
<<
"unexpected message; "
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
<<
to_string
(
self
->
last_dequeued
())
<<
endl
;
self
->
quit
(
exit_reason
::
user_defined
);
}
)
.
until
(
gref
(
s_pongs
)
==
num_pings
);
...
...
@@ -53,8 +55,10 @@ actor_ptr spawn_event_based_ping(size_t num_pings) {
}
},
others
()
>>
[]()
{
cout
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
cout
<<
"unexpected message; "
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
<<
to_string
(
self
->
last_dequeued
())
<<
endl
;
self
->
quit
(
exit_reason
::
user_defined
);
}
);
}
...
...
@@ -71,20 +75,10 @@ void pong(actor_ptr ping_actor) {
reply
(
atom
(
"pong"
),
value
+
1
);
},
others
()
>>
[]()
{
cout
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
cout
<<
"unexpected message; "
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
<<
to_string
(
self
->
last_dequeued
())
<<
endl
;
cout
<<
"trap_exit? => "
<<
std
::
boolalpha
<<
self
->
trap_exit
()
<<
endl
;
auto
&
arr
=
detail
::
static_types_array
<
atom_value
,
std
::
uint32_t
>::
arr
;
auto
msg
=
self
->
last_dequeued
();
if
(
msg
.
size
()
==
2
)
{
cout
<<
"msg.type_at(0) == arr[0] => "
<<
(
msg
.
type_at
(
0
)
==
arr
[
0
])
<<
endl
;
cout
<<
"msg.type_at(1) == arr[1] => "
<<
(
msg
.
type_at
(
1
)
==
arr
[
1
])
<<
endl
;
cout
<<
"msg.type_at(1)->name() => "
<<
(
msg
.
type_at
(
1
)
->
name
())
<<
endl
;
cout
<<
"arr[1]->name() => "
<<
(
arr
[
1
]
->
name
())
<<
endl
;
cout
<<
std
::
hex
<<
"arr[1] => "
<<
arr
[
1
]
<<
endl
;
cout
<<
"msg.type_at(1) => "
<<
msg
.
type_at
(
1
)
<<
endl
;
}
self
->
quit
(
exit_reason
::
normal
);
self
->
quit
(
exit_reason
::
user_defined
);
}
);
}
...
...
@@ -100,8 +94,10 @@ actor_ptr spawn_event_based_pong(actor_ptr ping_actor) {
reply
(
atom
(
"pong"
),
value
+
1
);
},
others
()
>>
[]()
{
cout
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
cout
<<
"unexpected message; "
<<
__FILE__
<<
" line "
<<
__LINE__
<<
": "
<<
to_string
(
self
->
last_dequeued
())
<<
endl
;
self
->
quit
(
exit_reason
::
user_defined
);
}
);
}
...
...
unit_testing/test__uniform_type.cpp
View file @
4a6eefe0
...
...
@@ -21,6 +21,7 @@
#include "cppa/deserializer.hpp"
#include "cppa/uniform_type_info.hpp"
#include "cppa/detail/types_array.hpp"
#include "cppa/detail/addressed_message.hpp"
#include "cppa/util/callable_trait.hpp"
...
...
@@ -76,7 +77,7 @@ size_t test__uniform_type() {
// default announced cppa types
"@atom"
,
// cppa::atom_value
"@<>"
,
// cppa::any_tuple
"@msg"
,
// cppa::message
"@msg"
,
// cppa::
detail::addressed_
message
"@actor"
,
// cppa::actor_ptr
"@group"
,
// cppa::group_ptr
"@channel"
,
// cppa::channel_ptr
...
...
@@ -110,7 +111,49 @@ size_t test__uniform_type() {
}
}
// check if static types are identical to runtime types
auto
&
sarr
=
detail
::
static_types_array
<
std
::
int8_t
,
std
::
int16_t
,
std
::
int32_t
,
std
::
int64_t
,
std
::
uint8_t
,
std
::
uint16_t
,
std
::
uint32_t
,
std
::
uint64_t
,
std
::
string
,
std
::
u16string
,
std
::
u32string
,
float
,
double
,
atom_value
,
any_tuple
,
detail
::
addressed_message
,
actor_ptr
,
group_ptr
,
channel_ptr
,
intrusive_ptr
<
process_information
>
>::
arr
;
std
::
vector
<
const
uniform_type_info
*>
rarr
{
uniform_typeid
<
std
::
int8_t
>
(),
uniform_typeid
<
std
::
int16_t
>
(),
uniform_typeid
<
std
::
int32_t
>
(),
uniform_typeid
<
std
::
int64_t
>
(),
uniform_typeid
<
std
::
uint8_t
>
(),
uniform_typeid
<
std
::
uint16_t
>
(),
uniform_typeid
<
std
::
uint32_t
>
(),
uniform_typeid
<
std
::
uint64_t
>
(),
uniform_typeid
<
std
::
string
>
(),
uniform_typeid
<
std
::
u16string
>
(),
uniform_typeid
<
std
::
u32string
>
(),
uniform_typeid
<
float
>
(),
uniform_typeid
<
double
>
(),
uniform_typeid
<
atom_value
>
(),
uniform_typeid
<
any_tuple
>
(),
uniform_typeid
<
detail
::
addressed_message
>
(),
uniform_typeid
<
actor_ptr
>
(),
uniform_typeid
<
group_ptr
>
(),
uniform_typeid
<
channel_ptr
>
(),
uniform_typeid
<
intrusive_ptr
<
process_information
>
>
()
};
CPPA_CHECK_EQUAL
(
true
,
sarr
.
is_pure
());
for
(
size_t
i
=
0
;
i
<
sarr
.
size
;
++
i
)
{
CPPA_CHECK_EQUAL
(
sarr
[
i
]
->
name
(),
rarr
[
i
]
->
name
());
CPPA_CHECK
(
sarr
[
i
]
==
rarr
[
i
]);
}
auto
&
arr0
=
detail
::
static_types_array
<
atom_value
,
std
::
uint32_t
>::
arr
;
CPPA_CHECK
(
arr0
.
is_pure
());
CPPA_CHECK
(
arr0
[
0
]
==
uniform_typeid
<
atom_value
>
());
CPPA_CHECK
(
arr0
[
0
]
==
uniform_type_info
::
from
(
"@atom"
));
CPPA_CHECK
(
arr0
[
1
]
==
uniform_typeid
<
std
::
uint32_t
>
());
...
...
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