16 #include "tensorflow_serving/util/threadpool_executor.h"
18 #include <gtest/gtest.h>
20 namespace tensorflow {
24 constexpr
int kNumThreads = 30;
26 TEST(ThreadPoolExecutor, Empty) {
27 for (
int num_threads = 1; num_threads < kNumThreads; num_threads++) {
28 LOG(INFO) <<
"Testing with " << num_threads <<
" threads";
29 ThreadPoolExecutor pool(Env::Default(),
"test", num_threads);
33 TEST(ThreadPoolExecutor, DoWork) {
34 for (
int num_threads = 1; num_threads < kNumThreads; num_threads++) {
35 LOG(INFO) <<
"Testing with " << num_threads <<
" threads";
36 const int kWorkItems = 15;
39 bool work[kWorkItems];
40 for (
int i = 0; i < kWorkItems; ++i) {
44 ThreadPoolExecutor executor(Env::Default(),
"test", num_threads);
45 for (
int i = 0; i < kWorkItems; i++) {
46 executor.Schedule([&work, i]() {
47 ASSERT_FALSE(work[i]);
52 for (
int i = 0; i < kWorkItems; i++) {