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
fb863af3
Commit
fb863af3
authored
Dec 08, 2017
by
Dominik Charousset
Committed by
Dominik Charousset
Feb 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve streaming unit test
parent
07734fb0
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
285 additions
and
41 deletions
+285
-41
libcaf_core/test/streaming_classes.cpp
libcaf_core/test/streaming_classes.cpp
+207
-41
libcaf_core/test/time_emitter.cpp
libcaf_core/test/time_emitter.cpp
+78
-0
No files found.
libcaf_core/test/streaming_classes.cpp
View file @
fb863af3
This diff is collapsed.
Click to expand it.
libcaf_core/test/time_emitter.cpp
0 → 100644
View file @
fb863af3
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2017 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
// This test simulates a complex multiplexing over multiple layers of WDRR
// scheduled queues. The goal is to reduce the complex mailbox management of
// CAF to its bare bones in order to test whether the multiplexing of stream
// traffic and asynchronous messages works as intended.
//
// The setup is a fixed WDRR queue with three nestes queues. The first nested
// queue stores asynchronous messages, the second one upstream messages, and
// the last queue is a dynamic WDRR queue storing downstream messages.
//
// We mock just enough of an actor to use the streaming classes and put them to
// work in a pipeline with 2 or 3 stages.
#define CAF_SUITE time_emitter
#include <vector>
#include "caf/detail/gcd.hpp"
#include "caf/detail/tick_emitter.hpp"
#include "caf/test/unit_test.hpp"
using
std
::
vector
;
using
namespace
caf
;
CAF_TEST
(
ticks
)
{
using
timespan
=
std
::
chrono
::
microseconds
;
timespan
credit_interval
{
200
};
timespan
force_batch_interval
{
50
};
auto
cycle
=
detail
::
gcd
(
credit_interval
.
count
(),
force_batch_interval
.
count
());
CAF_CHECK_EQUAL
(
cycle
,
50
);
auto
force_batch_frequency
=
force_batch_interval
.
count
()
/
cycle
;
auto
credit_frequency
=
credit_interval
.
count
()
/
cycle
;
using
time_point
=
std
::
chrono
::
steady_clock
::
time_point
;
detail
::
tick_emitter
tctrl
{
time_point
{
timespan
{
100
}}};
tctrl
.
interval
(
timespan
{
cycle
});
vector
<
long
>
ticks
;
int
force_batch_triggers
=
0
;
int
credit_triggers
=
0
;
auto
f
=
[
&
](
long
tick_id
)
{
ticks
.
push_back
(
tick_id
);
if
(
tick_id
%
force_batch_frequency
==
0
)
++
force_batch_triggers
;
if
(
tick_id
%
credit_frequency
==
0
)
++
credit_triggers
;
};
CAF_MESSAGE
(
"trigger 4 ticks"
);
tctrl
.
update
(
time_point
{
timespan
{
300
}},
f
);
CAF_CHECK_EQUAL
(
deep_to_string
(
ticks
),
"[1, 2, 3, 4]"
);
CAF_CHECK_EQUAL
(
force_batch_triggers
,
4
);
CAF_CHECK_EQUAL
(
credit_triggers
,
1
);
CAF_MESSAGE
(
"trigger 3 more ticks"
);
tctrl
.
update
(
time_point
{
timespan
{
475
}},
f
);
CAF_CHECK_EQUAL
(
deep_to_string
(
ticks
),
"[1, 2, 3, 4, 5, 6, 7]"
);
CAF_CHECK_EQUAL
(
force_batch_triggers
,
7
);
CAF_CHECK_EQUAL
(
credit_triggers
,
1
);
}
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