Browse Source

[master] use a wrapper for boost::function to work around sunstudio build issue

it can't handle it if we pass a function object directly to asio function
(also templated).  okayed on jabber.
JINMEI Tatuya 12 years ago
parent
commit
fd6c9be84e
1 changed files with 16 additions and 3 deletions
  1. 16 3
      src/lib/asiodns/sync_udp_server.h

+ 16 - 3
src/lib/asiodns/sync_udp_server.h

@@ -158,9 +158,22 @@ private:
     asio::error_code ec_;
     // The callback functor for internal asynchronous read event.  This is
     // stateless (and it will be copied in the ASIO library anyway), so
-    // can be const
-    const boost::function<void(const asio::error_code&, size_t)>
-    recv_callback_;
+    // can be const.
+    // SunStudio doesn't like a boost::function object to be passed, so
+    // we use the wrapper class as a workaround.
+    class CallbackWrapper {
+    public:
+        CallbackWrapper(boost::function<void(const asio::error_code&, size_t)>
+                        callback) :
+            callback_(callback)
+        {}
+        void operator()(const asio::error_code& error, size_t len) {
+            callback_(error, len);
+        }
+    private:
+        boost::function<void(const asio::error_code&, size_t)> callback_;
+    };
+    const CallbackWrapper recv_callback_;
 
     // Auxiliary functions