face: delete deprecated shared_ptr<io_service> constructor and getter

refs #2097

Change-Id: I98c9875f7a8bb4decf8e7a28ee3c5c60d163f7b5
diff --git a/src/detail/face-impl.hpp b/src/detail/face-impl.hpp
index 5e3558b..e4991ca 100644
--- a/src/detail/face-impl.hpp
+++ b/src/detail/face-impl.hpp
@@ -105,7 +105,7 @@
                        const OnData& onData, const OnTimeout& onTimeout)
   {
     if (!m_face.m_transport->isConnected())
-      m_face.m_transport->connect(*m_face.m_ioService,
+      m_face.m_transport->connect(m_face.m_ioService,
                                   bind(&Face::onReceiveElement, &m_face, _1));
 
     if (!m_face.m_transport->isExpectingData())
@@ -142,7 +142,7 @@
   asyncPutData(const shared_ptr<const Data>& data)
   {
     if (!m_face.m_transport->isConnected())
-      m_face.m_transport->connect(*m_face.m_ioService,
+      m_face.m_transport->connect(m_face.m_ioService,
                                   bind(&Face::onReceiveElement, &m_face, _1));
 
     if (!m_face.m_transport->isExpectingData())
diff --git a/src/face.cpp b/src/face.cpp
index cf2d1e4..dece828 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -32,102 +32,83 @@
 namespace ndn {
 
 Face::Face()
-  : m_internalKeyChain(new KeyChain())
+  : m_internalIoService(new boost::asio::io_service())
+  , m_ioService(*m_internalIoService)
+  , m_internalKeyChain(new KeyChain())
   , m_isDirectNfdFibManagementRequested(false)
   , m_impl(new Impl(*this))
 {
   const std::string socketName = UnixTransport::getDefaultSocketName(m_impl->m_config);
   construct(make_shared<UnixTransport>(socketName),
-            make_shared<boost::asio::io_service>(),
             m_internalKeyChain);
 }
 
-Face::Face(const shared_ptr<boost::asio::io_service>& ioService)
-  : m_internalKeyChain(new KeyChain())
-  , m_isDirectNfdFibManagementRequested(false)
-  , m_impl(new Impl(*this))
-{
-  const std::string socketName = UnixTransport::getDefaultSocketName(m_impl->m_config);
-  construct(make_shared<UnixTransport>(socketName),
-            ioService,
-            m_internalKeyChain);
-}
-
-class NullIoDeleter
-{
-public:
-  void
-  operator()(boost::asio::io_service*)
-  {
-  }
-};
-
 Face::Face(boost::asio::io_service& ioService)
-  : m_internalKeyChain(new KeyChain())
+  : m_ioService(ioService)
+  , m_internalKeyChain(new KeyChain())
   , m_isDirectNfdFibManagementRequested(false)
   , m_impl(new Impl(*this))
 {
   const std::string socketName = UnixTransport::getDefaultSocketName(m_impl->m_config);
   construct(make_shared<UnixTransport>(socketName),
-            shared_ptr<boost::asio::io_service>(&ioService, NullIoDeleter()),
             m_internalKeyChain);
 }
 
 Face::Face(const std::string& host, const std::string& port/* = "6363"*/)
-  : m_internalKeyChain(new KeyChain())
+  : m_internalIoService(new boost::asio::io_service())
+  , m_ioService(*m_internalIoService)
+  , m_internalKeyChain(new KeyChain())
   , m_impl(new Impl(*this))
 {
   construct(make_shared<TcpTransport>(host, port),
-            make_shared<boost::asio::io_service>(),
             m_internalKeyChain);
 }
 
 Face::Face(const shared_ptr<Transport>& transport)
-  : m_internalKeyChain(new KeyChain())
+  : m_internalIoService(new boost::asio::io_service())
+  , m_ioService(*m_internalIoService)
+  , m_internalKeyChain(new KeyChain())
   , m_isDirectNfdFibManagementRequested(false)
   , m_impl(new Impl(*this))
 {
   construct(transport,
-            make_shared<boost::asio::io_service>(),
             m_internalKeyChain);
 }
 
 Face::Face(const shared_ptr<Transport>& transport,
            boost::asio::io_service& ioService)
-  : m_internalKeyChain(new KeyChain())
+  : m_ioService(ioService)
+  , m_internalKeyChain(new KeyChain())
   , m_isDirectNfdFibManagementRequested(false)
   , m_impl(new Impl(*this))
 {
   construct(transport,
-            shared_ptr<boost::asio::io_service>(&ioService, NullIoDeleter()),
             m_internalKeyChain);
 }
 
 Face::Face(shared_ptr<Transport> transport,
            boost::asio::io_service& ioService,
            KeyChain& keyChain)
-  : m_internalKeyChain(nullptr)
+  : m_ioService(ioService)
+  , m_internalKeyChain(nullptr)
   , m_isDirectNfdFibManagementRequested(false)
   , m_impl(new Impl(*this))
 {
   construct(transport,
-            shared_ptr<boost::asio::io_service>(&ioService, NullIoDeleter()),
             &keyChain);
 }
 
 void
 Face::construct(shared_ptr<Transport> transport,
-                shared_ptr<boost::asio::io_service> ioService,
                 KeyChain* keyChain)
 {
   m_nfdController = new nfd::Controller(*this, *keyChain);
 
   m_impl->m_pitTimeoutCheckTimerActive = false;
   m_transport = transport;
-  m_ioService = ioService;
 
-  m_impl->m_pitTimeoutCheckTimer      = make_shared<monotonic_deadline_timer>(ref(*m_ioService));
-  m_impl->m_processEventsTimeoutTimer = make_shared<monotonic_deadline_timer>(ref(*m_ioService));
+  m_impl->m_pitTimeoutCheckTimer      = make_shared<monotonic_deadline_timer>(ref(m_ioService));
+  m_impl->m_processEventsTimeoutTimer = make_shared<monotonic_deadline_timer>(ref(m_ioService));
 
   std::string protocol = "nrd-0.1";
 
@@ -178,8 +159,8 @@
     throw Error("Interest size exceeds maximum limit");
 
   // If the same ioService thread, dispatch directly calls the method
-  m_ioService->dispatch(bind(&Impl::asyncExpressInterest, m_impl,
-                             interestToExpress, onData, onTimeout));
+  m_ioService.dispatch(bind(&Impl::asyncExpressInterest, m_impl,
+                            interestToExpress, onData, onTimeout));
 
   return reinterpret_cast<const PendingInterestId*>(interestToExpress.get());
 }
@@ -213,13 +194,13 @@
   }
 
   // If the same ioService thread, dispatch directly calls the method
-  m_ioService->dispatch(bind(&Impl::asyncPutData, m_impl, dataPtr));
+  m_ioService.dispatch(bind(&Impl::asyncPutData, m_impl, dataPtr));
 }
 
 void
 Face::removePendingInterest(const PendingInterestId* pendingInterestId)
 {
-  m_ioService->post(bind(&Impl::asyncRemovePendingInterest, m_impl, pendingInterestId));
+  m_ioService.post(bind(&Impl::asyncRemovePendingInterest, m_impl, pendingInterestId));
 }
 
 size_t
@@ -363,14 +344,14 @@
 void
 Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId)
 {
-  m_ioService->post(bind(&Impl::asyncUnregisterPrefix, m_impl, registeredPrefixId,
-                         UnregisterPrefixSuccessCallback(), UnregisterPrefixFailureCallback()));
+  m_ioService.post(bind(&Impl::asyncUnregisterPrefix, m_impl, registeredPrefixId,
+                        UnregisterPrefixSuccessCallback(), UnregisterPrefixFailureCallback()));
 }
 
 void
 Face::unsetInterestFilter(const InterestFilterId* interestFilterId)
 {
-  m_ioService->post(bind(&Impl::asyncUnsetInterestFilter, m_impl, interestFilterId));
+  m_ioService.post(bind(&Impl::asyncUnsetInterestFilter, m_impl, interestFilterId));
 }
 
 void
@@ -378,8 +359,8 @@
                        const UnregisterPrefixSuccessCallback& onSuccess,
                        const UnregisterPrefixFailureCallback& onFailure)
 {
-  m_ioService->post(bind(&Impl::asyncUnregisterPrefix, m_impl, registeredPrefixId,
-                         onSuccess, onFailure));
+  m_ioService.post(bind(&Impl::asyncUnregisterPrefix, m_impl, registeredPrefixId,
+                        onSuccess, onFailure));
 }
 
 void
@@ -390,7 +371,7 @@
     if (timeout < time::milliseconds::zero())
       {
         // do not block if timeout is negative, but process pending events
-        m_ioService->poll();
+        m_ioService.poll();
         return;
       }
 
@@ -402,20 +383,20 @@
 
     if (keepThread) {
       // work will ensure that m_ioService is running until work object exists
-      m_impl->m_ioServiceWork = make_shared<boost::asio::io_service::work>(ref(*m_ioService));
+      m_impl->m_ioServiceWork = make_shared<boost::asio::io_service::work>(ref(m_ioService));
     }
 
-    m_ioService->run();
-    m_ioService->reset(); // so it is possible to run processEvents again (if necessary)
+    m_ioService.run();
+    m_ioService.reset(); // so it is possible to run processEvents again (if necessary)
   }
   catch (Face::ProcessEventsTimeout&) {
     // break
     m_impl->m_ioServiceWork.reset();
-    m_ioService->reset();
+    m_ioService.reset();
   }
   catch (...) {
     m_impl->m_ioServiceWork.reset();
-    m_ioService->reset();
+    m_ioService.reset();
     m_impl->m_pendingInterestTable.clear();
     m_impl->m_registeredPrefixTable.clear();
     throw;
@@ -425,7 +406,7 @@
 void
 Face::shutdown()
 {
-  m_ioService->post(bind(&Face::asyncShutdown, this));
+  m_ioService.post(bind(&Face::asyncShutdown, this));
 }
 
 void
diff --git a/src/face.hpp b/src/face.hpp
index 19587dc..abc1d74 100644
--- a/src/face.hpp
+++ b/src/face.hpp
@@ -115,21 +115,6 @@
   /**
    * @brief Create a new Face using the default transport (UnixTransport)
    *
-   * @deprecated This constructor is deprecated.  Use `Face(boost::asio::io_service&)`
-   *             instead.
-   *
-   * @param ioService A shared pointer to boost::io_service object that should control all
-   *                  IO operations
-   * @throws ConfigFile::Error on configuration file parse failure
-   * @throws Face::Error on unsupported protocol
-   */
-  DEPRECATED(
-  explicit
-  Face(const shared_ptr<boost::asio::io_service>& ioService));
-
-  /**
-   * @brief Create a new Face using the default transport (UnixTransport)
-   *
    * @par Usage examples:
    *
    *     Face face1;
@@ -541,34 +526,21 @@
   shutdown();
 
   /**
-   * @brief Get shared_ptr of the IO service object
-   *
-   * @deprecated Use getIoService instead
-   */
-  DEPRECATED(
-  shared_ptr<boost::asio::io_service>
-  ioService())
-  {
-    return m_ioService;
-  }
-
-  /**
    * @brief Get reference to IO service object
    */
   boost::asio::io_service&
   getIoService()
   {
-    return *m_ioService;
+    return m_ioService;
   }
 
 private:
   /**
    * @throws Face::Error on unsupported protocol
-   * @note shared_ptrs are passed by value because ownership is transferred to this function
+   * @note shared_ptr is passed by value because ownership is transferred to this function
    */
   void
   construct(shared_ptr<Transport> transport,
-            shared_ptr<boost::asio::io_service> ioService,
             KeyChain* keyChain);
 
   bool
@@ -591,8 +563,10 @@
   fireProcessEventsTimeout(const boost::system::error_code& error);
 
 private:
-  /// @todo change to regular pointer after #2097
-  shared_ptr<boost::asio::io_service> m_ioService;
+  /// the IO service owned by this Face, could be null
+  unique_ptr<boost::asio::io_service> m_internalIoService;
+  /// the IO service used by this Face
+  boost::asio::io_service& m_ioService;
 
   shared_ptr<Transport> m_transport;