aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/thread_manager
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2017-11-14 19:04:02 -0800
committerGravatar Vijay Pai <vpai@google.com>2018-01-08 10:02:38 -0800
commit5dd32268be62114e8a7c81d60c0dc2633fb83081 (patch)
tree5d97aa70dfc6ea09df7da9e7955866d7574cb1e3 /test/cpp/thread_manager
parent669900c7de64d5992c92a838e23097b27e09d0b5 (diff)
Switch C++ sync server to use gpr_thd rather than std::thread and provide resource exhaustion mechanism
Diffstat (limited to 'test/cpp/thread_manager')
-rw-r--r--test/cpp/thread_manager/BUILD31
-rw-r--r--test/cpp/thread_manager/thread_manager_test.cc8
2 files changed, 35 insertions, 4 deletions
diff --git a/test/cpp/thread_manager/BUILD b/test/cpp/thread_manager/BUILD
new file mode 100644
index 0000000000..1f0878770b
--- /dev/null
+++ b/test/cpp/thread_manager/BUILD
@@ -0,0 +1,31 @@
+# Copyright 2017 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+licenses(["notice"]) # Apache v2
+
+load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package")
+
+grpc_package(name = "test/cpp/thread_manager")
+
+grpc_cc_test(
+ name = "thread_manager_test",
+ srcs = ["thread_manager_test.cc"],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//test/cpp/util:test_config",
+ ],
+)
+
diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc
index 8282d46694..d3d31f9dd9 100644
--- a/test/cpp/thread_manager/thread_manager_test.cc
+++ b/test/cpp/thread_manager/thread_manager_test.cc
@@ -20,10 +20,10 @@
#include <memory>
#include <string>
-#include <gflags/gflags.h>
#include <grpc++/grpc++.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
+#include <grpc/support/thd.h>
#include "src/cpp/thread_manager/thread_manager.h"
#include "test/cpp/util/test_config.h"
@@ -32,13 +32,13 @@ namespace grpc {
class ThreadManagerTest final : public grpc::ThreadManager {
public:
ThreadManagerTest()
- : ThreadManager(kMinPollers, kMaxPollers),
+ : ThreadManager(kMinPollers, kMaxPollers, gpr_thd_new, gpr_thd_join),
num_do_work_(0),
num_poll_for_work_(0),
num_work_found_(0) {}
grpc::ThreadManager::WorkStatus PollForWork(void** tag, bool* ok) override;
- void DoWork(void* tag, bool ok) override;
+ void DoWork(void* tag, bool ok, bool resources) override;
void PerformTest();
private:
@@ -89,7 +89,7 @@ grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void** tag,
}
}
-void ThreadManagerTest::DoWork(void* tag, bool ok) {
+void ThreadManagerTest::DoWork(void* tag, bool ok, bool resources) {
gpr_atm_no_barrier_fetch_add(&num_do_work_, 1);
SleepForMs(kDoWorkDurationMsec); // Simulate doing work by sleeping
}