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
ffb36f8f
Commit
ffb36f8f
authored
May 12, 2017
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow inlining of runnables in test multiplexer
parent
df903625
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
6 deletions
+40
-6
libcaf_io/caf/io/network/test_multiplexer.hpp
libcaf_io/caf/io/network/test_multiplexer.hpp
+21
-0
libcaf_io/src/test_multiplexer.cpp
libcaf_io/src/test_multiplexer.cpp
+19
-6
No files found.
libcaf_io/caf/io/network/test_multiplexer.hpp
View file @
ffb36f8f
...
@@ -154,6 +154,21 @@ public:
...
@@ -154,6 +154,21 @@ public:
/// Executes all pending `runnable` objects.
/// Executes all pending `runnable` objects.
void
flush_runnables
();
void
flush_runnables
();
/// Executes the next `num` enqueued runnables immediately.
inline
void
inline_next_runnables
(
size_t
num
)
{
inline_runnables_
+=
num
;
}
/// Executes the next enqueued runnable immediately.
inline
void
inline_next_runnable
()
{
inline_next_runnables
(
1
);
}
/// Installs a callback that is triggered on the next inlined runnable.
inline
void
after_next_inlined_runnable
(
std
::
function
<
void
()
>
f
)
{
inline_runnable_callback_
=
std
::
move
(
f
);
}
protected:
protected:
void
exec_later
(
resumable
*
ptr
)
override
;
void
exec_later
(
resumable
*
ptr
)
override
;
...
@@ -207,6 +222,12 @@ private:
...
@@ -207,6 +222,12 @@ private:
// extra state for making sure the test multiplexer is not used in a
// extra state for making sure the test multiplexer is not used in a
// multithreaded setup
// multithreaded setup
std
::
thread
::
id
tid_
;
std
::
thread
::
id
tid_
;
// Configures shortcuts for runnables.
size_t
inline_runnables_
;
// Configures a one-shot handler for the next inlined runnable.
std
::
function
<
void
()
>
inline_runnable_callback_
;
};
};
}
// namespace network
}
// namespace network
...
...
libcaf_io/src/test_multiplexer.cpp
View file @
ffb36f8f
...
@@ -49,7 +49,8 @@ test_multiplexer::doorman_data::doorman_data()
...
@@ -49,7 +49,8 @@ test_multiplexer::doorman_data::doorman_data()
test_multiplexer
::
test_multiplexer
(
actor_system
*
sys
)
test_multiplexer
::
test_multiplexer
(
actor_system
*
sys
)
:
multiplexer
(
sys
),
:
multiplexer
(
sys
),
tid_
(
std
::
this_thread
::
get_id
())
{
tid_
(
std
::
this_thread
::
get_id
()),
inline_runnables_
(
0
)
{
CAF_ASSERT
(
sys
!=
nullptr
);
CAF_ASSERT
(
sys
!=
nullptr
);
}
}
...
@@ -527,11 +528,23 @@ void test_multiplexer::exec_later(resumable* ptr) {
...
@@ -527,11 +528,23 @@ void test_multiplexer::exec_later(resumable* ptr) {
switch
(
ptr
->
subtype
())
{
switch
(
ptr
->
subtype
())
{
case
resumable
:
:
io_actor
:
case
resumable
:
:
io_actor
:
case
resumable
:
:
function_object
:
{
case
resumable
:
:
function_object
:
{
std
::
list
<
resumable_ptr
>
tmp
;
if
(
inline_runnables_
>
0
)
{
tmp
.
emplace_back
(
ptr
);
--
inline_runnables_
;
guard_type
guard
{
mx_
};
resumable_ptr
tmp
{
ptr
};
resumables_
.
splice
(
resumables_
.
end
(),
std
::
move
(
tmp
));
exec
(
tmp
);
cv_
.
notify_all
();
if
(
inline_runnable_callback_
)
{
using
std
::
swap
;
std
::
function
<
void
()
>
f
;
swap
(
f
,
inline_runnable_callback_
);
f
();
}
}
else
{
std
::
list
<
resumable_ptr
>
tmp
;
tmp
.
emplace_back
(
ptr
);
guard_type
guard
{
mx_
};
resumables_
.
splice
(
resumables_
.
end
(),
std
::
move
(
tmp
));
cv_
.
notify_all
();
}
break
;
break
;
}
}
default:
default:
...
...
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