update thrift to use managed connection
authorDave Watson <davejwatson@fb.com>
Wed, 24 Sep 2014 17:52:50 +0000 (10:52 -0700)
committerAnton Likhtarov <alikhtarov@fb.com>
Fri, 26 Sep 2014 22:23:37 +0000 (15:23 -0700)
Summary:
Use the new managed connection code in folly.  Cleans things up a fair bit

The only catch was the current ConnectionManager code uses raw pointers, thrift expects shared_ptr so the request object can keep the channel around until the requests are finished

Test Plan: fbconfig -r thrift/lib/cpp2; fbmake runtests

Reviewed By: afrind@fb.com

Subscribers: trunkagent, njormrod, doug, fugalh, alandau, bmatheny, dcsommer, afrind

FB internal diff: D1519923

Tasks: 5002343

folly/experimental/wangle/ConnectionManager.h

index 30117e435221eb67fc9435d8adf172d9d25c8cd2..9ac356d662ef1205be595c513f2872561b8bc120 100644 (file)
@@ -121,6 +121,15 @@ class ConnectionManager: public folly::DelayedDestruction {
 
   size_t getNumConnections() const { return conns_.size(); }
 
+  template <typename F>
+  void iterateConns(F func) {
+    auto it = conns_.begin();
+    while ( it != conns_.end()) {
+      func(&(*it));
+      it++;
+    }
+  }
+
  private:
   class CloseIdleConnsCallback :
       public folly::EventBase::LoopCallback,