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
f6762dfc
Commit
f6762dfc
authored
Jan 22, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove type_token from messages
parent
5370dd5d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
16 additions
and
139 deletions
+16
-139
libcaf_core/caf/detail/decorated_tuple.hpp
libcaf_core/caf/detail/decorated_tuple.hpp
+2
-21
libcaf_core/caf/detail/message_data.hpp
libcaf_core/caf/detail/message_data.hpp
+1
-18
libcaf_core/caf/detail/tuple_vals.hpp
libcaf_core/caf/detail/tuple_vals.hpp
+3
-6
libcaf_core/caf/match_expr.hpp
libcaf_core/caf/match_expr.hpp
+4
-40
libcaf_core/caf/message.hpp
libcaf_core/caf/message.hpp
+0
-9
libcaf_core/src/decorated_tuple.cpp
libcaf_core/src/decorated_tuple.cpp
+2
-21
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+0
-8
libcaf_core/src/message_builder.cpp
libcaf_core/src/message_builder.cpp
+3
-3
libcaf_core/src/message_data.cpp
libcaf_core/src/message_data.cpp
+1
-10
libcaf_core/src/uniform_type_info_map.cpp
libcaf_core/src/uniform_type_info_map.cpp
+0
-3
No files found.
libcaf_core/caf/detail/decorated_tuple.hpp
View file @
f6762dfc
...
@@ -47,28 +47,16 @@ class decorated_tuple : public message_data {
...
@@ -47,28 +47,16 @@ class decorated_tuple : public message_data {
using
pointer
=
message_data
::
ptr
;
using
pointer
=
message_data
::
ptr
;
using
rtti
=
const
std
::
type_info
*
;
// creates a typed subtuple from `d` with mapping `v`
// creates a dynamically typed subtuple from `d` with an offset
static
inline
pointer
create
(
pointer
d
,
vector_type
v
)
{
static
inline
pointer
create
(
pointer
d
,
vector_type
v
)
{
return
pointer
{
new
decorated_tuple
(
std
::
move
(
d
),
std
::
move
(
v
))};
return
pointer
{
new
decorated_tuple
(
std
::
move
(
d
),
std
::
move
(
v
))};
}
}
// creates a statically typed subtuple from `d` with an offset
// creates a typed subtuple from `d` with an offset
static
inline
pointer
create
(
pointer
d
,
rtti
ti
,
vector_type
v
)
{
return
pointer
{
new
decorated_tuple
(
std
::
move
(
d
),
ti
,
std
::
move
(
v
))};
}
// creates a dynamically typed subtuple from `d` with an offset
static
inline
pointer
create
(
pointer
d
,
size_t
offset
)
{
static
inline
pointer
create
(
pointer
d
,
size_t
offset
)
{
return
pointer
{
new
decorated_tuple
(
std
::
move
(
d
),
offset
)};
return
pointer
{
new
decorated_tuple
(
std
::
move
(
d
),
offset
)};
}
}
// creates a statically typed subtuple from `d` with an offset
static
inline
pointer
create
(
pointer
d
,
rtti
ti
,
size_t
offset
)
{
return
pointer
{
new
decorated_tuple
(
std
::
move
(
d
),
ti
,
offset
)};
}
void
*
mutable_at
(
size_t
pos
)
override
;
void
*
mutable_at
(
size_t
pos
)
override
;
size_t
size
()
const
override
;
size_t
size
()
const
override
;
...
@@ -81,12 +69,9 @@ class decorated_tuple : public message_data {
...
@@ -81,12 +69,9 @@ class decorated_tuple : public message_data {
const
std
::
string
*
tuple_type_names
()
const
override
;
const
std
::
string
*
tuple_type_names
()
const
override
;
rtti
type_token
()
const
override
;
private:
private:
pointer
m_decorated
;
pointer
m_decorated
;
rtti
m_token
;
vector_type
m_mapping
;
vector_type
m_mapping
;
void
init
();
void
init
();
...
@@ -95,12 +80,8 @@ class decorated_tuple : public message_data {
...
@@ -95,12 +80,8 @@ class decorated_tuple : public message_data {
decorated_tuple
(
pointer
,
size_t
);
decorated_tuple
(
pointer
,
size_t
);
decorated_tuple
(
pointer
,
rtti
,
size_t
);
decorated_tuple
(
pointer
,
vector_type
&&
);
decorated_tuple
(
pointer
,
vector_type
&&
);
decorated_tuple
(
pointer
,
rtti
,
vector_type
&&
);
decorated_tuple
(
const
decorated_tuple
&
)
=
default
;
decorated_tuple
(
const
decorated_tuple
&
)
=
default
;
};
};
...
...
libcaf_core/caf/detail/message_data.hpp
View file @
f6762dfc
...
@@ -42,8 +42,7 @@ class message_data : public ref_counted {
...
@@ -42,8 +42,7 @@ class message_data : public ref_counted {
public:
public:
message_data
(
bool
dynamically_typed
);
message_data
();
message_data
(
const
message_data
&
other
);
// mutators
// mutators
virtual
void
*
mutable_at
(
size_t
pos
)
=
0
;
virtual
void
*
mutable_at
(
size_t
pos
)
=
0
;
...
@@ -60,17 +59,6 @@ class message_data : public ref_counted {
...
@@ -60,17 +59,6 @@ class message_data : public ref_counted {
// is not a 'native' implementation
// is not a 'native' implementation
virtual
const
void
*
native_data
()
const
;
virtual
const
void
*
native_data
()
const
;
// Identifies the type of the implementation.
// A statically typed tuple implementation can use some optimizations,
// e.g., "impl_type() == statically_typed" implies that type_token()
// identifies all possible instances of a given tuple implementation
inline
bool
dynamically_typed
()
const
{
return
m_is_dynamic
;
}
// uniquely identifies this category (element types) of messages
// override this member function only if impl_type() == statically_typed
// (default returns &typeid(void))
virtual
const
std
::
type_info
*
type_token
()
const
;
bool
equals
(
const
message_data
&
other
)
const
;
bool
equals
(
const
message_data
&
other
)
const
;
using
const_iterator
=
message_iterator
;
using
const_iterator
=
message_iterator
;
...
@@ -125,11 +113,6 @@ class message_data : public ref_counted {
...
@@ -125,11 +113,6 @@ class message_data : public ref_counted {
intrusive_ptr
<
message_data
>
m_ptr
;
intrusive_ptr
<
message_data
>
m_ptr
;
};
};
private:
bool
m_is_dynamic
;
};
};
std
::
string
get_tuple_type_names
(
const
detail
::
message_data
&
);
std
::
string
get_tuple_type_names
(
const
detail
::
message_data
&
);
...
...
libcaf_core/caf/detail/tuple_vals.hpp
View file @
f6762dfc
...
@@ -69,8 +69,9 @@ class tuple_vals : public message_data {
...
@@ -69,8 +69,9 @@ class tuple_vals : public message_data {
tuple_vals
(
const
tuple_vals
&
)
=
default
;
tuple_vals
(
const
tuple_vals
&
)
=
default
;
template
<
class
...
Us
>
template
<
class
...
Us
>
tuple_vals
(
Us
&&
...
args
)
tuple_vals
(
Us
&&
...
args
)
:
m_data
(
std
::
forward
<
Us
>
(
args
)...)
{
:
super
(
false
),
m_data
(
std
::
forward
<
Us
>
(
args
)...)
{}
// nop
}
const
void
*
native_data
()
const
{
return
&
m_data
;
}
const
void
*
native_data
()
const
{
return
&
m_data
;
}
...
@@ -108,10 +109,6 @@ class tuple_vals : public message_data {
...
@@ -108,10 +109,6 @@ class tuple_vals : public message_data {
return
message_data
::
equals
(
other
);
return
message_data
::
equals
(
other
);
}
}
const
std
::
type_info
*
type_token
()
const
{
return
detail
::
static_type_list
<
Ts
...
>::
list
;
}
const
std
::
string
*
tuple_type_names
()
const
override
{
const
std
::
string
*
tuple_type_names
()
const
override
{
// produced name is equal for all instances
// produced name is equal for all instances
static
std
::
string
result
=
get_tuple_type_names
(
*
this
);
static
std
::
string
result
=
get_tuple_type_names
(
*
this
);
...
...
libcaf_core/caf/match_expr.hpp
View file @
f6762dfc
...
@@ -208,23 +208,19 @@ T& unroll_expr_result_unbox(optional<T>& opt) {
...
@@ -208,23 +208,19 @@ T& unroll_expr_result_unbox(optional<T>& opt) {
}
}
template
<
class
Result
,
class
PPFPs
,
class
Msg
>
template
<
class
Result
,
class
PPFPs
,
class
Msg
>
Result
unroll_expr
(
PPFPs
&
,
uint64_t
,
minus1l
,
Msg
&
)
{
Result
unroll_expr
(
PPFPs
&
,
minus1l
,
Msg
&
)
{
// end of recursion
// end of recursion
return
none
;
return
none
;
}
}
template
<
class
Result
,
class
PPFPs
,
long
N
,
class
Msg
>
template
<
class
Result
,
class
PPFPs
,
long
N
,
class
Msg
>
Result
unroll_expr
(
PPFPs
&
fs
,
uint64_t
bitmask
,
long_constant
<
N
>
,
Msg
&
msg
)
{
Result
unroll_expr
(
PPFPs
&
fs
,
long_constant
<
N
>
,
Msg
&
msg
)
{
{
// recursively evaluate sub expressions
{
// recursively evaluate sub expressions
Result
res
=
unroll_expr
<
Result
>
(
fs
,
bitmask
,
long_constant
<
N
-
1
>
{},
msg
);
Result
res
=
unroll_expr
<
Result
>
(
fs
,
long_constant
<
N
-
1
>
{},
msg
);
if
(
!
get
<
none_t
>
(
&
res
))
{
if
(
!
get
<
none_t
>
(
&
res
))
{
return
res
;
return
res
;
}
}
}
}
if
((
bitmask
&
(
0x01
<<
N
))
==
0
)
{
// case is disabled via bitmask
return
none
;
}
auto
&
f
=
get
<
N
>
(
fs
);
auto
&
f
=
get
<
N
>
(
fs
);
using
ft
=
typename
std
::
decay
<
decltype
(
f
)
>::
type
;
using
ft
=
typename
std
::
decay
<
decltype
(
f
)
>::
type
;
meta_elements
<
typename
ft
::
pattern
>
ms
;
meta_elements
<
typename
ft
::
pattern
>
ms
;
...
@@ -430,37 +426,6 @@ class match_expr {
...
@@ -430,37 +426,6 @@ class match_expr {
i
=
(
i
+
1
)
%
cache_size
;
i
=
(
i
+
1
)
%
cache_size
;
}
}
size_t
find_token_pos
(
const
std
::
type_info
*
type_token
)
{
for
(
size_t
i
=
m_cache_begin
;
i
!=
m_cache_end
;
advance_
(
i
))
{
if
(
m_cache
[
i
].
first
==
type_token
)
{
return
i
;
}
}
return
m_cache_end
;
}
template
<
class
Tuple
>
uint64_t
get_cache_entry
(
const
std
::
type_info
*
type_token
,
const
Tuple
&
value
)
{
CAF_REQUIRE
(
type_token
!=
nullptr
);
if
(
value
.
dynamically_typed
())
{
return
m_dummy
.
second
;
// all groups enabled
}
size_t
i
=
find_token_pos
(
type_token
);
// if we didn't found a cache entry ...
if
(
i
==
m_cache_end
)
{
// ... 'create' one (override oldest element in cache if full)
advance_
(
m_cache_end
);
if
(
m_cache_end
==
m_cache_begin
)
{
advance_
(
m_cache_begin
);
}
m_cache
[
i
].
first
=
type_token
;
idx_token_type
idx_token
;
m_cache
[
i
].
second
=
calc_bitmask
(
m_cases
,
idx_token
,
*
type_token
,
value
);
}
return
m_cache
[
i
].
second
;
}
void
init
()
{
void
init
()
{
m_dummy
.
second
=
std
::
numeric_limits
<
uint64_t
>::
max
();
m_dummy
.
second
=
std
::
numeric_limits
<
uint64_t
>::
max
();
m_cache
.
resize
(
cache_size
);
m_cache
.
resize
(
cache_size
);
...
@@ -477,8 +442,7 @@ class match_expr {
...
@@ -477,8 +442,7 @@ class match_expr {
// returns either a reference or a new object
// returns either a reference or a new object
using
detached
=
decltype
(
detail
::
detach_if_needed
(
msg
,
mutator_token
));
using
detached
=
decltype
(
detail
::
detach_if_needed
(
msg
,
mutator_token
));
detached
mref
=
detail
::
detach_if_needed
(
msg
,
mutator_token
);
detached
mref
=
detail
::
detach_if_needed
(
msg
,
mutator_token
);
auto
bitmask
=
get_cache_entry
(
mref
.
type_token
(),
mref
);
return
detail
::
unroll_expr
<
result_type
>
(
m_cases
,
idx_token
,
mref
);
return
detail
::
unroll_expr
<
result_type
>
(
m_cases
,
bitmask
,
idx_token
,
mref
);
}
}
};
};
...
...
libcaf_core/caf/message.hpp
View file @
f6762dfc
...
@@ -210,15 +210,6 @@ class message {
...
@@ -210,15 +210,6 @@ class message {
return
m_vals
;
return
m_vals
;
}
}
/**
* Returns either `&typeid(detail::type_list<Ts...>)`, where
* `Ts...` are the element types, or `&typeid(void)`.
*
* The type token `&typeid(void)` indicates that this tuple is dynamically
* typed, i.e., the types where not available at compile time.
*/
const
std
::
type_info
*
type_token
()
const
;
/**
/**
* Checks whether this tuple is dynamically typed, i.e.,
* Checks whether this tuple is dynamically typed, i.e.,
* its types were not known at compile time.
* its types were not known at compile time.
...
...
libcaf_core/src/decorated_tuple.cpp
View file @
f6762dfc
...
@@ -43,10 +43,6 @@ const uniform_type_info* decorated_tuple::type_at(size_t pos) const {
...
@@ -43,10 +43,6 @@ const uniform_type_info* decorated_tuple::type_at(size_t pos) const {
return
m_decorated
->
type_at
(
m_mapping
[
pos
]);
return
m_decorated
->
type_at
(
m_mapping
[
pos
]);
}
}
auto
decorated_tuple
::
type_token
()
const
->
rtti
{
return
m_token
;
}
void
decorated_tuple
::
init
()
{
void
decorated_tuple
::
init
()
{
CAF_REQUIRE
(
m_mapping
.
empty
()
CAF_REQUIRE
(
m_mapping
.
empty
()
||
*
(
std
::
max_element
(
m_mapping
.
begin
(),
m_mapping
.
end
()))
||
*
(
std
::
max_element
(
m_mapping
.
begin
(),
m_mapping
.
end
()))
...
@@ -64,28 +60,13 @@ void decorated_tuple::init(size_t offset) {
...
@@ -64,28 +60,13 @@ void decorated_tuple::init(size_t offset) {
}
}
decorated_tuple
::
decorated_tuple
(
pointer
d
,
vector_type
&&
v
)
decorated_tuple
::
decorated_tuple
(
pointer
d
,
vector_type
&&
v
)
:
super
(
true
),
:
m_decorated
(
std
::
move
(
d
)),
m_decorated
(
std
::
move
(
d
)),
m_token
(
&
typeid
(
void
)),
m_mapping
(
std
::
move
(
v
))
{
init
();
}
decorated_tuple
::
decorated_tuple
(
pointer
d
,
rtti
ti
,
vector_type
&&
v
)
:
super
(
false
),
m_decorated
(
std
::
move
(
d
)),
m_token
(
ti
),
m_mapping
(
std
::
move
(
v
))
{
m_mapping
(
std
::
move
(
v
))
{
init
();
init
();
}
}
decorated_tuple
::
decorated_tuple
(
pointer
d
,
size_t
offset
)
decorated_tuple
::
decorated_tuple
(
pointer
d
,
size_t
offset
)
:
super
(
true
),
m_decorated
(
std
::
move
(
d
)),
m_token
(
&
typeid
(
void
))
{
:
m_decorated
(
std
::
move
(
d
))
{
init
(
offset
);
}
decorated_tuple
::
decorated_tuple
(
pointer
d
,
rtti
ti
,
size_t
offset
)
:
super
(
false
),
m_decorated
(
std
::
move
(
d
)),
m_token
(
ti
)
{
init
(
offset
);
init
(
offset
);
}
}
...
...
libcaf_core/src/message.cpp
View file @
f6762dfc
...
@@ -95,14 +95,6 @@ optional<message> message::apply(message_handler handler) {
...
@@ -95,14 +95,6 @@ optional<message> message::apply(message_handler handler) {
return
handler
(
*
this
);
return
handler
(
*
this
);
}
}
const
std
::
type_info
*
message
::
type_token
()
const
{
return
m_vals
?
m_vals
->
type_token
()
:
&
typeid
(
detail
::
empty_type_list
);
}
bool
message
::
dynamically_typed
()
const
{
return
m_vals
?
m_vals
->
dynamically_typed
()
:
false
;
}
message
::
const_iterator
message
::
begin
()
const
{
message
::
const_iterator
message
::
begin
()
const
{
return
m_vals
?
m_vals
->
begin
()
:
const_iterator
{
nullptr
,
0
};
return
m_vals
?
m_vals
->
begin
()
:
const_iterator
{
nullptr
,
0
};
}
}
...
...
libcaf_core/src/message_builder.cpp
View file @
f6762dfc
...
@@ -31,18 +31,18 @@ class message_builder::dynamic_msg_data : public detail::message_data {
...
@@ -31,18 +31,18 @@ class message_builder::dynamic_msg_data : public detail::message_data {
using
message_data
::
const_iterator
;
using
message_data
::
const_iterator
;
dynamic_msg_data
()
:
super
(
true
)
{
dynamic_msg_data
()
{
// nop
// nop
}
}
dynamic_msg_data
(
const
dynamic_msg_data
&
other
)
:
super
(
true
)
{
dynamic_msg_data
(
const
dynamic_msg_data
&
other
)
{
for
(
auto
&
d
:
other
.
m_elements
)
{
for
(
auto
&
d
:
other
.
m_elements
)
{
m_elements
.
push_back
(
d
->
copy
());
m_elements
.
push_back
(
d
->
copy
());
}
}
}
}
dynamic_msg_data
(
std
::
vector
<
uniform_value
>&&
data
)
dynamic_msg_data
(
std
::
vector
<
uniform_value
>&&
data
)
:
super
(
true
),
m_elements
(
std
::
move
(
data
))
{
:
m_elements
(
std
::
move
(
data
))
{
// nop
// nop
}
}
...
...
libcaf_core/src/message_data.cpp
View file @
f6762dfc
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
namespace
caf
{
namespace
caf
{
namespace
detail
{
namespace
detail
{
message_data
::
message_data
(
bool
is_dynamic
)
:
m_is_dynamic
(
is_dynamic
)
{
message_data
::
message_data
()
{
// nop
// nop
}
}
...
@@ -36,15 +36,6 @@ bool message_data::equals(const message_data& other) const {
...
@@ -36,15 +36,6 @@ bool message_data::equals(const message_data& other) const {
&&
std
::
equal
(
begin
(),
end
(),
other
.
begin
(),
full_eq
));
&&
std
::
equal
(
begin
(),
end
(),
other
.
begin
(),
full_eq
));
}
}
message_data
::
message_data
(
const
message_data
&
other
)
:
super
(),
m_is_dynamic
(
other
.
m_is_dynamic
)
{
// nop
}
const
std
::
type_info
*
message_data
::
type_token
()
const
{
return
&
typeid
(
void
);
}
const
void
*
message_data
::
native_data
()
const
{
const
void
*
message_data
::
native_data
()
const
{
return
nullptr
;
return
nullptr
;
}
}
...
...
libcaf_core/src/uniform_type_info_map.cpp
View file @
f6762dfc
...
@@ -136,9 +136,6 @@ inline bool operator==(const unit_t&, const unit_t&) {
...
@@ -136,9 +136,6 @@ inline bool operator==(const unit_t&, const unit_t&) {
return
true
;
return
true
;
}
}
template
<
class
T
>
struct
type_token
{
};
template
<
class
T
>
template
<
class
T
>
inline
typename
std
::
enable_if
<
detail
::
is_primitive
<
T
>::
value
>::
type
inline
typename
std
::
enable_if
<
detail
::
is_primitive
<
T
>::
value
>::
type
serialize_impl
(
const
T
&
val
,
serializer
*
sink
)
{
serialize_impl
(
const
T
&
val
,
serializer
*
sink
)
{
...
...
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