You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bb...@apache.org on 2018/07/16 20:18:57 UTC
mesos git commit: Removed potentially unneeded lambda capture.
Repository: mesos
Updated Branches:
refs/heads/master da8cac169 -> 1467120b1
Removed potentially unneeded lambda capture.
In some instances variables used in the body of a lambda do not need
to be captured explicitly, see e.g.,
https://stackoverflow.com/a/43468519/176922. Support for this across
compiler vendors seems to be incomplete at this point; while e.g.,
clang emits a warning (which we potentially turn into a fatal error)
for this, msvc still seems to require such variables to be captured.
To provide a warning free build this patch moves from the usually
preferred explicit capture list to an implicit capture by reference.
This allows us to capture all needed variables correctly without
having to capture too much.
Review: https://reviews.apache.org/r/67927
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1467120b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1467120b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1467120b
Branch: refs/heads/master
Commit: 1467120b13384f6b66ac729f277834b82d64ed2c
Parents: da8cac1
Author: Benjamin Bannier <bb...@apache.org>
Authored: Mon Jul 16 14:32:55 2018 +0200
Committer: Benjamin Bannier <bb...@apache.org>
Committed: Mon Jul 16 21:32:29 2018 +0200
----------------------------------------------------------------------
3rdparty/libprocess/src/tests/benchmarks.cpp | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1467120b/3rdparty/libprocess/src/tests/benchmarks.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/benchmarks.cpp b/3rdparty/libprocess/src/tests/benchmarks.cpp
index e8ef21f..e63f116 100644
--- a/3rdparty/libprocess/src/tests/benchmarks.cpp
+++ b/3rdparty/libprocess/src/tests/benchmarks.cpp
@@ -716,7 +716,16 @@ TEST(ProcessTest, Process_BENCHMARK_MpscLinkedQueue)
producerWatch.start();
for (unsigned int t = 0; t < producerCount; t++) {
- producers.push_back(std::thread([messageCount, s, &q]() {
+ // We want to capture `messageCount`, `s`, and `&q` here. Since
+ // `messageCount` is a constant integer variable initialized with a
+ // compile-time expression in a "reaching scope", it can get captured
+ // without being mentioned in the capture list, see. e.g.,
+ // https://stackoverflow.com/a/43468519/176922.
+ //
+ // We capture implicitly instead of explicitly since this part of the
+ // standard is not supported by msvc, while clang supports it and emits a
+ // warning for unneeded captures.
+ producers.push_back(std::thread([&]() {
for (int i = 0; i < messageCount; i++) {
q.enqueue(s);
}