Merge pull request #1135 from vjpai/fix_gcc_4_4

Remove lambda expression from grpc C++ library and make a fake nullptr
pull/1127/merge
Nicolas Noble 10 years ago
commit a8891c0e37
  1. 3
      .travis.yml
  2. 22
      include/grpc++/config.h
  3. 41
      src/cpp/server/thread_pool.cc
  4. 2
      src/cpp/server/thread_pool.h
  5. 21
      tools/run_tests/run_tests.py

@ -19,9 +19,12 @@ env:
- CONFIG=opt TEST=python
- CONFIG=gcov TEST=c
- CONFIG=gcov TEST=c++
- USE_GCC=4.4 CONFIG=opt TEST=build
- USE_GCC=4.5 CONFIG=opt TEST=build
script:
- rvm use $RUBY_VERSION
- gem install bundler
- if [ ! -z "$USE_GCC" ] ; then export CC=gcc-$USE_GCC ; export CXX=g++-$USE_GCC ; fi
- ./tools/run_tests/run_tests.py -l $TEST -t -j 16 -c $CONFIG -s 4.0
after_success:
- if [ "$CONFIG" = "gcov" ] ; then coveralls --exclude third_party --exclude gens -b. --gcov-options '\-p' ; fi

@ -65,6 +65,28 @@
::google::protobuf::io::ZeroCopyInputStream
#endif
#ifndef __clang__
#ifdef __GNUC__
#if (__GNUC__ * 100 + __GNUC_MINOR__ < 406)
#define GRPC_NO_NULLPTR
#endif
#endif
#endif
#ifdef GRPC_NO_NULLPTR
#include <memory>
const class {
public:
template <class T> operator T*() const {return static_cast<T *>(0);}
template <class T> operator std::unique_ptr<T>() const {
return std::unique_ptr<T>(static_cast<T *>(0));
}
operator bool() const {return false;}
private:
void operator&() const = delete;
} nullptr = {};
#endif
namespace grpc {
typedef GRPC_CUSTOM_STRING string;

@ -35,28 +35,29 @@
namespace grpc {
void ThreadPool::ThreadFunc() {
for (;;) {
// Wait until work is available or we are shutting down.
std::unique_lock<std::mutex> lock(mu_);
if (!shutdown_ && callbacks_.empty()) {
cv_.wait(lock);
}
// Drain callbacks before considering shutdown to ensure all work
// gets completed.
if (!callbacks_.empty()) {
auto cb = callbacks_.front();
callbacks_.pop();
lock.unlock();
cb();
} else if (shutdown_) {
return;
}
}
}
ThreadPool::ThreadPool(int num_threads) : shutdown_(false) {
for (int i = 0; i < num_threads; i++) {
threads_.push_back(std::thread([this]() {
for (;;) {
// Wait until work is available or we are shutting down.
auto have_work = [this]() { return shutdown_ || !callbacks_.empty(); };
std::unique_lock<std::mutex> lock(mu_);
if (!have_work()) {
cv_.wait(lock, have_work);
}
// Drain callbacks before considering shutdown to ensure all work
// gets completed.
if (!callbacks_.empty()) {
auto cb = callbacks_.front();
callbacks_.pop();
lock.unlock();
cb();
} else if (shutdown_) {
return;
}
}
}));
threads_.push_back(std::thread(&ThreadPool::ThreadFunc, this));
}
}

@ -58,6 +58,8 @@ class ThreadPool GRPC_FINAL : public ThreadPoolInterface {
bool shutdown_;
std::queue<std::function<void()>> callbacks_;
std::vector<std::thread> threads_;
void ThreadFunc();
};
} // namespace grpc

@ -224,6 +224,24 @@ class CSharpLanguage(object):
def __str__(self):
return 'csharp'
class Build(object):
def test_specs(self, config, travis):
return []
def make_targets(self):
return ['all']
def build_steps(self):
return []
def supports_multi_config(self):
return True
def __str__(self):
return self.make_target
# different configurations we can run under
_CONFIGS = {
'dbg': SimpleConfig('dbg'),
@ -248,7 +266,8 @@ _LANGUAGES = {
'php': PhpLanguage(),
'python': PythonLanguage(),
'ruby': RubyLanguage(),
'csharp': CSharpLanguage()
'csharp': CSharpLanguage(),
'build': Build(),
}
# parse command line

Loading…
Cancel
Save