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
4d89c25f
Commit
4d89c25f
authored
Jul 07, 2017
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hooking API to testing scheduler API
parent
181c56ec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
20 deletions
+21
-20
libcaf_core/caf/scheduler/test_coordinator.hpp
libcaf_core/caf/scheduler/test_coordinator.hpp
+11
-1
libcaf_core/src/test_coordinator.cpp
libcaf_core/src/test_coordinator.cpp
+10
-19
No files found.
libcaf_core/caf/scheduler/test_coordinator.hpp
View file @
4d89c25f
...
...
@@ -102,7 +102,12 @@ public:
}
/// Tries to execute a single event.
bool
run_once
();
bool
try_run_once
();
/// Deprecated. Use `try_run_once()` instead.
inline
bool
run_once
()
CAF_DEPRECATED
{
return
try_run_once
();
}
/// Executes events until the job queue is empty and no pending timeouts are
/// left. Returns the number of processed events.
...
...
@@ -134,6 +139,10 @@ public:
inline_enqueues_
=
num
;
}
/// The function used for inlining enqueue operations. The default predicate
/// calls `run()`.
std
::
function
<
void
()
>
inlining_hook
;
protected:
void
start
()
override
;
...
...
@@ -143,6 +152,7 @@ protected:
private:
size_t
inline_enqueues_
;
bool
inside_inlined_enqueue
;
};
}
// namespace scheduler
...
...
libcaf_core/src/test_coordinator.cpp
View file @
4d89c25f
...
...
@@ -95,7 +95,9 @@ private:
test_coordinator
::
test_coordinator
(
actor_system
&
sys
)
:
super
(
sys
),
inline_enqueues_
(
0
)
{
// nop
inlining_hook
=
[
=
]
{
run
();
};
}
void
test_coordinator
::
start
()
{
dummy_worker
worker
{
this
};
...
...
@@ -113,27 +115,16 @@ void test_coordinator::stop() {
void
test_coordinator
::
enqueue
(
resumable
*
ptr
)
{
CAF_LOG_TRACE
(
""
);
if
(
inline_enqueues_
>
0
)
{
--
inline_enqueues_
;
CAF_LOG_DEBUG
(
"inline actor execution, remaining:"
<<
inline_enqueues_
);
dummy_worker
worker
{
this
};
switch
(
ptr
->
resume
(
&
worker
,
1
))
{
case
resumable
:
:
resume_later
:
enqueue
(
ptr
);
break
;
case
resumable
:
:
done
:
case
resumable
:
:
awaiting_message
:
intrusive_ptr_release
(
ptr
);
break
;
case
resumable
:
:
shutdown_execution_unit
:
break
;
}
}
else
{
jobs
.
push_back
(
ptr
);
if
(
!
inside_inlined_enqueue
&&
inline_enqueues_
>
0
)
{
--
inline_enqueues_
;
inside_inlined_enqueue
=
true
;
inlining_hook
();
inside_inlined_enqueue
=
false
;
}
}
bool
test_coordinator
::
run_once
()
{
bool
test_coordinator
::
try_
run_once
()
{
if
(
jobs
.
empty
())
return
false
;
auto
job
=
jobs
.
front
();
...
...
@@ -155,7 +146,7 @@ bool test_coordinator::run_once() {
size_t
test_coordinator
::
run
(
size_t
max_count
)
{
size_t
res
=
0
;
while
(
res
<
max_count
&&
run_once
())
while
(
res
<
max_count
&&
try_
run_once
())
++
res
;
return
res
;
}
...
...
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