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
73e3848f
Commit
73e3848f
authored
Oct 30, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support expected((void), ...), add run_once
parent
8607ad2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
libcaf_test/caf/test/dsl.hpp
libcaf_test/caf/test/dsl.hpp
+66
-0
No files found.
libcaf_test/caf/test/dsl.hpp
View file @
73e3848f
...
...
@@ -376,6 +376,65 @@ protected:
std
::
function
<
void
()
>
peek_
;
};
template
<
>
class
expect_clause
<
void
>
{
public:
expect_clause
(
caf
::
scheduler
::
test_coordinator
&
sched
)
:
sched_
(
sched
),
dest_
(
nullptr
)
{
// nop
}
expect_clause
(
expect_clause
&&
other
)
=
default
;
~
expect_clause
()
{
auto
ptr
=
dest_
->
peek_at_next_mailbox_element
();
if
(
ptr
==
nullptr
)
CAF_FAIL
(
"no message found"
);
if
(
!
ptr
->
content
().
empty
())
CAF_FAIL
(
"non-empty message found: "
<<
to_string
(
ptr
->
content
()));
run_once
();
}
expect_clause
&
from
(
const
wildcard
&
)
{
return
*
this
;
}
template
<
class
Handle
>
expect_clause
&
from
(
const
Handle
&
whom
)
{
src_
=
caf
::
actor_cast
<
caf
::
strong_actor_ptr
>
(
whom
);
return
*
this
;
}
template
<
class
Handle
>
expect_clause
&
to
(
const
Handle
&
whom
)
{
CAF_REQUIRE
(
sched_
.
prioritize
(
whom
));
dest_
=
&
sched_
.
next_job
<
caf
::
abstract_actor
>
();
auto
ptr
=
dest_
->
peek_at_next_mailbox_element
();
CAF_REQUIRE
(
ptr
!=
nullptr
);
if
(
src_
)
CAF_REQUIRE_EQUAL
(
ptr
->
sender
,
src_
);
return
*
this
;
}
expect_clause
&
to
(
const
caf
::
scoped_actor
&
whom
)
{
dest_
=
whom
.
ptr
();
return
*
this
;
}
protected:
void
run_once
()
{
auto
dptr
=
dynamic_cast
<
caf
::
blocking_actor
*>
(
dest_
);
if
(
dptr
==
nullptr
)
sched_
.
run_once
();
else
dptr
->
dequeue
();
// Drop message.
}
caf
::
scheduler
::
test_coordinator
&
sched_
;
caf
::
strong_actor_ptr
src_
;
caf
::
abstract_actor
*
dest_
;
};
template
<
class
...
Ts
>
class
inject_clause
{
public:
...
...
@@ -717,6 +776,13 @@ public:
return
run_until
([]
{
return
false
;
});
}
/// Consume ones message or triggers the next timeout.
/// @returns `true` if a message was consumed or timeouts was triggered,
/// `false` otherwise.
bool
run_once
()
{
return
run_until
([]
{
return
true
;
})
>
0
;
}
/// Consume messages and trigger timeouts until `pred` becomes `true` or
/// until no activity remains.
/// @returns The total number of events, i.e., messages consumed and
...
...
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