h2load: Don't use std::future with --disable-threads
Now we don't use std::future with --disable-threads, checking std::future in configure.ac was removed and building h2load is always enabled.
This commit is contained in:
parent
32ddca532a
commit
7a09feebc3
18
configure.ac
18
configure.ac
|
@ -162,23 +162,6 @@ auto tp = std::chrono::steady_clock::now();
|
||||||
AC_MSG_RESULT([yes])],
|
AC_MSG_RESULT([yes])],
|
||||||
[AC_MSG_RESULT([no])])
|
[AC_MSG_RESULT([no])])
|
||||||
|
|
||||||
# Check that std::future is available.
|
|
||||||
AC_MSG_CHECKING([whether std::future is available])
|
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
|
||||||
[[
|
|
||||||
#include <vector>
|
|
||||||
#include <future>
|
|
||||||
]],
|
|
||||||
[[
|
|
||||||
std::vector<std::future<int>> v;
|
|
||||||
]])],
|
|
||||||
[AC_DEFINE([HAVE_STD_FUTURE], [1],
|
|
||||||
[Define to 1 if you have the `std::future`.])
|
|
||||||
have_std_future=yes
|
|
||||||
AC_MSG_RESULT([yes])],
|
|
||||||
[have_std_future=no
|
|
||||||
AC_MSG_RESULT([no])])
|
|
||||||
|
|
||||||
AC_LANG_POP()
|
AC_LANG_POP()
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
|
@ -369,7 +352,6 @@ if test "x${request_app}" = "xyes" &&
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AM_CONDITIONAL([ENABLE_APP], [ test "x${enable_app}" = "xyes" ])
|
AM_CONDITIONAL([ENABLE_APP], [ test "x${enable_app}" = "xyes" ])
|
||||||
AM_CONDITIONAL([ENABLE_H2LOAD], [ test "x${have_std_future}" = "xyes" ])
|
|
||||||
|
|
||||||
enable_hpack_tools=no
|
enable_hpack_tools=no
|
||||||
# HPACK tools requires jansson
|
# HPACK tools requires jansson
|
||||||
|
|
|
@ -78,8 +78,6 @@ nghttpd_SOURCES = ${HELPER_OBJECTS} ${HELPER_HFILES} nghttpd.cc \
|
||||||
ssl.cc ssl.h \
|
ssl.cc ssl.h \
|
||||||
HttpServer.cc HttpServer.h
|
HttpServer.cc HttpServer.h
|
||||||
|
|
||||||
if ENABLE_H2LOAD
|
|
||||||
|
|
||||||
bin_PROGRAMS += h2load
|
bin_PROGRAMS += h2load
|
||||||
|
|
||||||
h2load_SOURCES = util.cc util.h libevent_util.cc libevent_util.h \
|
h2load_SOURCES = util.cc util.h libevent_util.cc libevent_util.h \
|
||||||
|
@ -93,8 +91,6 @@ if HAVE_SPDYLAY
|
||||||
h2load_SOURCES += h2load_spdy_session.cc h2load_spdy_session.h
|
h2load_SOURCES += h2load_spdy_session.cc h2load_spdy_session.h
|
||||||
endif # HAVE_SPDYLAY
|
endif # HAVE_SPDYLAY
|
||||||
|
|
||||||
endif # ENABLE_H2LOAD
|
|
||||||
|
|
||||||
NGHTTPX_SRCS = \
|
NGHTTPX_SRCS = \
|
||||||
util.cc util.h http2.cc http2.h timegm.c timegm.h base64.h \
|
util.cc util.h http2.cc http2.h timegm.c timegm.h base64.h \
|
||||||
libevent_util.cc libevent_util.h \
|
libevent_util.cc libevent_util.h \
|
||||||
|
|
|
@ -577,15 +577,6 @@ std::string get_reqline(const char *uri, const http_parser_url& u)
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
|
||||||
Stats run(std::unique_ptr<Worker> worker)
|
|
||||||
{
|
|
||||||
worker->run();
|
|
||||||
|
|
||||||
return worker->stats;
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
int client_select_next_proto_cb(SSL* ssl,
|
int client_select_next_proto_cb(SSL* ssl,
|
||||||
unsigned char **out, unsigned char *outlen,
|
unsigned char **out, unsigned char *outlen,
|
||||||
|
@ -931,10 +922,10 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
std::cout << "starting benchmark..." << std::endl;
|
std::cout << "starting benchmark..." << std::endl;
|
||||||
|
|
||||||
std::vector<std::future<Stats>> futures;
|
|
||||||
auto start = std::chrono::steady_clock::now();
|
auto start = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Worker>> workers;
|
#ifndef NOTHREADS
|
||||||
|
std::vector<std::future<Stats>> futures;
|
||||||
for(size_t i = 0; i < config.nthreads - 1; ++i) {
|
for(size_t i = 0; i < config.nthreads - 1; ++i) {
|
||||||
auto nreqs = nreqs_per_thread + (nreqs_rem-- > 0);
|
auto nreqs = nreqs_per_thread + (nreqs_rem-- > 0);
|
||||||
auto nclients = nclients_per_thread + (nclients_rem-- > 0);
|
auto nclients = nclients_per_thread + (nclients_rem-- > 0);
|
||||||
|
@ -944,8 +935,17 @@ int main(int argc, char **argv)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
auto worker = util::make_unique<Worker>(i, ssl_ctx, nreqs, nclients,
|
auto worker = util::make_unique<Worker>(i, ssl_ctx, nreqs, nclients,
|
||||||
&config);
|
&config);
|
||||||
futures.push_back(std::async(std::launch::async, run, std::move(worker)));
|
futures.push_back
|
||||||
|
(std::async(std::launch::async,
|
||||||
|
[](std::unique_ptr<Worker> worker)
|
||||||
|
{
|
||||||
|
worker->run();
|
||||||
|
|
||||||
|
return worker->stats;
|
||||||
|
}, std::move(worker)));
|
||||||
}
|
}
|
||||||
|
#endif // NOTHREADS
|
||||||
|
|
||||||
auto nreqs_last = nreqs_per_thread + (nreqs_rem-- > 0);
|
auto nreqs_last = nreqs_per_thread + (nreqs_rem-- > 0);
|
||||||
auto nclients_last = nclients_per_thread + (nclients_rem-- > 0);
|
auto nclients_last = nclients_per_thread + (nclients_rem-- > 0);
|
||||||
std::cout << "spawning thread #" << (config.nthreads - 1) << ": "
|
std::cout << "spawning thread #" << (config.nthreads - 1) << ": "
|
||||||
|
@ -956,6 +956,7 @@ int main(int argc, char **argv)
|
||||||
&config);
|
&config);
|
||||||
worker.run();
|
worker.run();
|
||||||
|
|
||||||
|
#ifndef NOTHREADS
|
||||||
for(auto& fut : futures) {
|
for(auto& fut : futures) {
|
||||||
auto stats = fut.get();
|
auto stats = fut.get();
|
||||||
|
|
||||||
|
@ -973,6 +974,7 @@ int main(int argc, char **argv)
|
||||||
worker.stats.status[i] += stats.status[i];
|
worker.stats.status[i] += stats.status[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // NOTHREADS
|
||||||
|
|
||||||
auto end = std::chrono::steady_clock::now();
|
auto end = std::chrono::steady_clock::now();
|
||||||
auto duration =
|
auto duration =
|
||||||
|
|
Loading…
Reference in New Issue