Various minor fixes
@ -76,9 +76,9 @@ class lock_guard {
template <class mutex>
class unique_lock : public lock_guard<mutex> {
public:
unique_lock(mutex &mu) : lock_guard(mu) { }
void lock() { lock_internal(); }
void unlock() { unlock_internal(); }
unique_lock(mutex &mu) : lock_guard<mutex>(mu) { }
void lock() { this->lock_internal(); }
void unlock() { this->unlock_internal(); }
};
class condition_variable {
@ -82,6 +82,10 @@ class thread {
thread_function_base *func_;
gpr_thd_id thd_;
bool joined_;
// Disallow copy and assign.
thread(const thread&);
void operator=(const thread&);
} // namespace grpc
@ -60,7 +60,7 @@ void ThreadPool::ThreadFunc() {
ThreadPool::ThreadPool(int num_threads) : shutdown_(false) {
for (int i = 0; i < num_threads; i++) {
threads_.push_back(grpc::thread(&ThreadPool::ThreadFunc, this));
threads_.push_back(new grpc::thread(&ThreadPool::ThreadFunc, this));
}
@ -71,7 +71,8 @@ ThreadPool::~ThreadPool() {
cv_.notify_all();
for (auto t = threads_.begin(); t != threads_.end(); t++) {
t->join();
(*t)->join();
delete *t;
@ -57,7 +57,7 @@ class ThreadPool GRPC_FINAL : public ThreadPoolInterface {
grpc::condition_variable cv_;
bool shutdown_;
std::queue<std::function<void()>> callbacks_;
std::vector<grpc::thread> threads_;
std::vector<grpc::thread*> threads_;
void ThreadFunc();
@ -54,6 +54,7 @@ static void thd_body(void *arg) {
gpr_tls_set(&test_var, i);
GPR_ASSERT(gpr_tls_get(&test_var) == i);
gpr_tls_set(&test_var, 0);
/* ------------------------------------------------- */
@ -31,6 +31,7 @@
*
*/
#include <mutex>
#include <thread>
#include "src/core/security/credentials.h"
#include "test/core/util/port.h"