Skip to content

Commit

Permalink
Merge pull request grpc#1857 from yang-g/test
Browse files Browse the repository at this point in the history
Various minor fixes
  • Loading branch information
ctiller committed Jun 2, 2015
2 parents e53a282 + 69fe075 commit 795b242
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/grpc++/impl/sync_no_cxx11.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions include/grpc++/impl/thd_no_cxx11.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/cpp/server/thread_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand All @@ -71,7 +71,8 @@ ThreadPool::~ThreadPool() {
cv_.notify_all();
}
for (auto t = threads_.begin(); t != threads_.end(); t++) {
t->join();
(*t)->join();
delete *t;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/server/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
1 change: 1 addition & 0 deletions test/core/support/tls_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/* ------------------------------------------------- */
Expand Down
1 change: 1 addition & 0 deletions test/cpp/end2end/end2end_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
*/

#include <mutex>
#include <thread>

#include "src/core/security/credentials.h"
Expand Down
1 change: 1 addition & 0 deletions test/cpp/end2end/thread_stress_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
*/

#include <mutex>
#include <thread>

#include "test/core/util/port.h"
Expand Down

0 comments on commit 795b242

Please sign in to comment.