THRIFT-5599: contrib/fb303 does not compile after C++ library refactorings
Patch: Michael Leinartas

This closes #2624
diff --git a/contrib/fb303/cpp/FacebookBase.cpp b/contrib/fb303/cpp/FacebookBase.cpp
index eb2e63c..d6a44a2 100644
--- a/contrib/fb303/cpp/FacebookBase.cpp
+++ b/contrib/fb303/cpp/FacebookBase.cpp
@@ -47,74 +47,70 @@
 }
 
 int64_t FacebookBase::incrementCounter(const std::string& key, int64_t amount) {
-  counters_.acquireRead();
+  counters_.lock();
 
   // if we didn't find the key, we need to write lock the whole map to create it
   ReadWriteCounterMap::iterator it = counters_.find(key);
   if (it == counters_.end()) {
-    counters_.release();
-    counters_.acquireWrite();
 
     // we need to check again to make sure someone didn't create this key
     // already while we released the lock
     it = counters_.find(key);
     if(it == counters_.end()){
       counters_[key].value = amount;
-      counters_.release();
+      counters_.unlock();
       return amount;
     }
   }
 
-  it->second.acquireWrite();
+  it->second.lock();
   int64_t count = it->second.value + amount;
   it->second.value = count;
-  it->second.release();
-  counters_.release();
+  it->second.unlock();
+  counters_.unlock();
   return count;
 }
 
 int64_t FacebookBase::setCounter(const std::string& key, int64_t value) {
-  counters_.acquireRead();
+  counters_.lock();
 
   // if we didn't find the key, we need to write lock the whole map to create it
   ReadWriteCounterMap::iterator it = counters_.find(key);
   if (it == counters_.end()) {
-    counters_.release();
-    counters_.acquireWrite();
     counters_[key].value = value;
-    counters_.release();
+    counters_.unlock();
     return value;
   }
 
-  it->second.acquireWrite();
+  it->second.lock();
   it->second.value = value;
-  it->second.release();
-  counters_.release();
+  it->second.unlock();
+  counters_.unlock();
   return value;
 }
 
 void FacebookBase::getCounters(std::map<std::string, int64_t>& _return) {
   // we need to lock the whole thing and actually build the map since we don't
   // want our read/write structure to go over the wire
-  counters_.acquireRead();
+  counters_.lock();
   for(ReadWriteCounterMap::iterator it = counters_.begin();
       it != counters_.end(); ++it)
   {
     _return[it->first] = it->second.value;
   }
-  counters_.release();
+  counters_.unlock();
 }
 
 int64_t FacebookBase::getCounter(const std::string& key) {
   int64_t rv = 0;
-  counters_.acquireRead();
+  counters_.lock();
   ReadWriteCounterMap::iterator it = counters_.find(key);
   if (it != counters_.end()) {
-    it->second.acquireRead();
+    it->second.lock();
     rv = it->second.value;
-    it->second.release();
+    it->second.unlock();
   }
-  counters_.release();
+  counters_.unlock();
   return rv;
 }
 
diff --git a/contrib/fb303/cpp/FacebookBase.h b/contrib/fb303/cpp/FacebookBase.h
index e0be4bf..0e4107d 100644
--- a/contrib/fb303/cpp/FacebookBase.h
+++ b/contrib/fb303/cpp/FacebookBase.h
@@ -33,11 +33,10 @@
 namespace facebook { namespace fb303 {
 
 using apache::thrift::concurrency::Mutex;
-using apache::thrift::concurrency::ReadWriteMutex;
 using apache::thrift::server::TServer;
 
-struct ReadWriteInt : ReadWriteMutex {int64_t value;};
-struct ReadWriteCounterMap : ReadWriteMutex,
+struct ReadWriteInt : Mutex {int64_t value;};
+struct ReadWriteCounterMap : Mutex,
                              std::map<std::string, ReadWriteInt> {};
 
 /**
diff --git a/contrib/fb303/cpp/Makefile.am b/contrib/fb303/cpp/Makefile.am
index 748d329..0d68b4e 100644
--- a/contrib/fb303/cpp/Makefile.am
+++ b/contrib/fb303/cpp/Makefile.am
@@ -47,7 +47,7 @@
 # Use <progname|libname>_<FLAG> to set prog / lib specific flag s
 # foo_CXXFLAGS foo_CPPFLAGS foo_LDFLAGS foo_LDADD
 
-fb303_lib = gen-cpp/FacebookService.cpp gen-cpp/fb303_constants.cpp gen-cpp/fb303_types.cpp FacebookBase.cpp ServiceTracker.cpp
+fb303_lib = gen-cpp/FacebookService.cpp gen-cpp/fb303_types.cpp FacebookBase.cpp ServiceTracker.cpp
 
 # Static -- multiple libraries can be defined
 if STATIC
@@ -71,7 +71,7 @@
 $(eval $(call thrift_template,.,../if/fb303.thrift,-I $(thrift_home)/share  --gen cpp:pure_enums ))
 
 include_fb303dir = $(includedir)/thrift/fb303
-include_fb303_HEADERS = FacebookBase.h ServiceTracker.h gen-cpp/FacebookService.h gen-cpp/fb303_constants.h gen-cpp/fb303_types.h
+include_fb303_HEADERS = FacebookBase.h ServiceTracker.h gen-cpp/FacebookService.h gen-cpp/fb303_types.h
 
 include_fb303ifdir = $(prefix)/share/fb303/if
 include_fb303if_HEADERS = ../if/fb303.thrift