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
59293798
Commit
59293798
authored
Aug 18, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove experimental code from aout unit test
parent
49e426b8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
189 deletions
+0
-189
libcaf_core/test/aout.cpp
libcaf_core/test/aout.cpp
+0
-189
No files found.
libcaf_core/test/aout.cpp
View file @
59293798
...
...
@@ -30,67 +30,6 @@ using std::endl;
namespace
{
struct
meta_info
{
constexpr
meta_info
(
const
char
*
x
,
size_t
y
,
uint32_t
z
)
:
name
(
x
),
hash
(
y
),
version
(
z
)
{
// nop
}
constexpr
meta_info
(
const
meta_info
&
other
)
:
name
(
other
.
name
),
hash
(
other
.
hash
),
version
(
other
.
version
)
{
// nop
}
const
char
*
name
;
size_t
hash
;
uint32_t
version
;
};
constexpr
size_t
str_hash
(
const
char
*
cstr
,
size_t
interim
=
0
)
{
return
(
*
cstr
==
'\0'
)
?
interim
:
str_hash
(
cstr
+
1
,
interim
*
101
+
*
cstr
);
}
constexpr
meta_info
make_meta_info
(
const
char
*
name
,
uint32_t
version
)
{
return
meta_info
{
name
,
str_hash
(
name
),
version
};
}
template
<
class
T
>
struct
meta_information
;
#define CAF_META_INFORMATION(class_name, version) \
template <> \
struct meta_information<class_name> { \
static constexpr meta_info value = make_meta_info(#class_name, version); \
}; \
constexpr meta_info meta_information<class_name>::value;
#define DUMMY(name) \
class name {}; \
CAF_META_INFORMATION(name, 0)
DUMMY
(
foo1
)
DUMMY
(
foo2
)
DUMMY
(
foo3
)
DUMMY
(
foo4
)
DUMMY
(
foo5
)
DUMMY
(
foo6
)
DUMMY
(
foo7
)
DUMMY
(
foo8
)
DUMMY
(
foo9
)
DUMMY
(
foo10
)
DUMMY
(
foo11
)
DUMMY
(
foo12
)
DUMMY
(
foo13
)
DUMMY
(
foo14
)
DUMMY
(
foo15
)
DUMMY
(
foo16
)
DUMMY
(
foo17
)
DUMMY
(
foo18
)
DUMMY
(
foo19
)
DUMMY
(
foo20
)
struct
fixture
{
~
fixture
()
{
await_all_actors_done
();
...
...
@@ -98,7 +37,6 @@ struct fixture {
}
};
constexpr
const
char
*
global_redirect
=
":test"
;
constexpr
const
char
*
local_redirect
=
":test2"
;
...
...
@@ -119,133 +57,6 @@ void chattier_actor(event_based_actor* self, const std::string& fn) {
CAF_TEST_FIXTURE_SCOPE
(
aout_tests
,
fixture
)
const
meta_info
*
lookup
(
const
std
::
vector
<
std
::
pair
<
size_t
,
const
meta_info
*>>&
haystack
,
const
meta_info
*
needle
)
{
/*
auto h = needle->hash;
auto e = haystack.end();
for (auto i = haystack.begin(); i != e; ++i) {
if (i->first == h) {
auto n = i + 1;
if (n == e || n->second->hash != h)
return i->second;
for (auto j = i; j != e; ++j)
if (strcmp(j->second->name, needle->name) == 0)
return j->second;
}
}
*/
auto
h
=
needle
->
hash
;
auto
e
=
haystack
.
end
();
//auto i = std::find_if(haystack.begin(), e,
// [h](const std::pair<size_t, const meta_info*>& x ) { return x.first == h; });
auto
i
=
std
::
lower_bound
(
haystack
.
begin
(),
e
,
h
,
[](
const
std
::
pair
<
size_t
,
const
meta_info
*>&
x
,
size_t
y
)
{
return
x
.
first
<
y
;
});
if
(
i
==
e
||
i
->
first
!=
h
)
return
nullptr
;
// check for collision
auto
n
=
i
+
1
;
if
(
n
==
e
||
n
->
first
!=
h
)
return
i
->
second
;
i
=
std
::
find_if
(
i
,
e
,
[
needle
](
const
std
::
pair
<
size_t
,
const
meta_info
*>&
x
)
{
return
strcmp
(
x
.
second
->
name
,
needle
->
name
)
==
0
;
});
if
(
i
!=
e
)
return
i
->
second
;
return
nullptr
;
}
const
meta_info
*
lookup
(
std
::
unordered_multimap
<
size_t
,
const
meta_info
*>&
haystack
,
const
meta_info
*
needle
)
{
auto
i
=
haystack
.
find
(
needle
->
hash
);
auto
e
=
haystack
.
end
();
if
(
i
==
e
)
return
nullptr
;
auto
n
=
std
::
next
(
i
);
if
(
n
==
e
||
n
->
second
->
hash
!=
i
->
second
->
hash
)
return
i
->
second
;
for
(;
i
!=
e
;
++
i
)
if
(
strcmp
(
i
->
second
->
name
,
needle
->
name
)
==
0
)
return
i
->
second
;
return
nullptr
;
}
const
meta_info
*
lookup
(
std
::
multimap
<
size_t
,
const
meta_info
*>&
haystack
,
const
meta_info
*
needle
)
{
auto
i
=
haystack
.
find
(
needle
->
hash
);
auto
e
=
haystack
.
end
();
if
(
i
==
e
)
return
nullptr
;
auto
n
=
std
::
next
(
i
);
if
(
n
==
e
||
n
->
second
->
hash
!=
i
->
second
->
hash
)
return
i
->
second
;
for
(;
i
!=
e
;
++
i
)
if
(
strcmp
(
i
->
second
->
name
,
needle
->
name
)
==
0
)
return
i
->
second
;
return
nullptr
;
}
CAF_TEST
(
foobar
)
{
using
std
::
make_pair
;
std
::
vector
<
std
::
pair
<
size_t
,
const
meta_info
*>>
map1
;
std
::
unordered_multimap
<
size_t
,
const
meta_info
*>
map2
;
std
::
multimap
<
size_t
,
const
meta_info
*>
map3
;
const
meta_info
*
arr
[]
=
{
&
meta_information
<
foo1
>::
value
,
&
meta_information
<
foo2
>::
value
,
&
meta_information
<
foo3
>::
value
,
&
meta_information
<
foo4
>::
value
,
&
meta_information
<
foo5
>::
value
,
&
meta_information
<
foo6
>::
value
,
&
meta_information
<
foo7
>::
value
,
&
meta_information
<
foo8
>::
value
,
&
meta_information
<
foo9
>::
value
,
&
meta_information
<
foo10
>::
value
,
&
meta_information
<
foo11
>::
value
,
&
meta_information
<
foo12
>::
value
,
&
meta_information
<
foo13
>::
value
,
&
meta_information
<
foo14
>::
value
,
&
meta_information
<
foo15
>::
value
,
&
meta_information
<
foo16
>::
value
,
&
meta_information
<
foo17
>::
value
,
&
meta_information
<
foo18
>::
value
,
&
meta_information
<
foo19
>::
value
,
&
meta_information
<
foo20
>::
value
};
for
(
auto
i
=
std
::
begin
(
arr
);
i
!=
std
::
end
(
arr
);
++
i
)
{
map1
.
emplace_back
((
*
i
)
->
hash
,
*
i
);
map2
.
emplace
((
*
i
)
->
hash
,
*
i
);
map3
.
emplace
((
*
i
)
->
hash
,
*
i
);
}
std
::
sort
(
map1
.
begin
(),
map1
.
end
());
std
::
array
<
const
meta_info
*
,
20
>
dummy
;
{
auto
t0
=
std
::
chrono
::
high_resolution_clock
::
now
();
for
(
auto
i
=
0
;
i
<
10000
;
++
i
)
dummy
[
i
%
20
]
=
lookup
(
map1
,
arr
[
i
%
20
]);
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
std
::
cout
<<
"vector: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t1
-
t0
).
count
()
<<
std
::
endl
;
std
::
cout
<<
"check: "
<<
std
::
equal
(
dummy
.
begin
(),
dummy
.
end
(),
std
::
begin
(
arr
))
<<
std
::
endl
;
}
{
auto
t0
=
std
::
chrono
::
high_resolution_clock
::
now
();
for
(
auto
i
=
0
;
i
<
10000
;
++
i
)
dummy
[
i
%
20
]
=
lookup
(
map2
,
arr
[
i
%
20
]);
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
std
::
cout
<<
"hash map: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t1
-
t0
).
count
()
<<
std
::
endl
;
std
::
cout
<<
"check: "
<<
std
::
equal
(
dummy
.
begin
(),
dummy
.
end
(),
std
::
begin
(
arr
))
<<
std
::
endl
;
}
{
auto
t0
=
std
::
chrono
::
high_resolution_clock
::
now
();
for
(
auto
i
=
0
;
i
<
10000
;
++
i
)
dummy
[
i
%
20
]
=
lookup
(
map3
,
arr
[
i
%
20
]);
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
std
::
cout
<<
"map: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t1
-
t0
).
count
()
<<
std
::
endl
;
std
::
cout
<<
"check: "
<<
std
::
equal
(
dummy
.
begin
(),
dummy
.
end
(),
std
::
begin
(
arr
))
<<
std
::
endl
;
}
CAF_CHECK
(
meta_information
<
foo1
>::
value
.
name
==
"foo1"
);
CAF_CHECK
(
meta_information
<
foo1
>::
value
.
hash
==
str_hash
(
"foo1"
));
CAF_CHECK
(
meta_information
<
foo1
>::
value
.
version
==
0
);
}
CAF_TEST
(
global_redirect
)
{
scoped_actor
self
;
self
->
join
(
group
::
get
(
"local"
,
global_redirect
));
...
...
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