LCOV - code coverage report
Current view: top level - asiolink - io_service.cc (source / functions) Hit Total Coverage
Test: report.info Lines: 22 22 100.0 %
Date: 2012-05-15 Functions: 9 9 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
       2                 :            : //
       3                 :            : // Permission to use, copy, modify, and/or distribute this software for any
       4                 :            : // purpose with or without fee is hereby granted, provided that the above
       5                 :            : // copyright notice and this permission notice appear in all copies.
       6                 :            : //
       7                 :            : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
       8                 :            : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       9                 :            : // AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
      10                 :            : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      11                 :            : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
      12                 :            : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      13                 :            : // PERFORMANCE OF THIS SOFTWARE.
      14                 :            : 
      15                 :            : #include <config.h>
      16                 :            : 
      17                 :            : #include <unistd.h>             // for some IPC/network system calls
      18                 :            : #include <netinet/in.h>
      19                 :            : #include <sys/socket.h>
      20                 :            : 
      21                 :            : #include <asio.hpp>
      22                 :            : #include <asiolink/io_service.h>
      23                 :            : 
      24                 :            : namespace isc {
      25                 :            : namespace asiolink {
      26                 :            : 
      27                 :            : class IOServiceImpl {
      28                 :            : private:
      29                 :            :     IOServiceImpl(const IOService& source);
      30                 :            :     IOServiceImpl& operator=(const IOService& source);
      31                 :            : public:
      32                 :            :     /// \brief The constructor
      33                 :            :     IOServiceImpl() :
      34                 :            :         io_service_(),
      35                 :        388 :         work_(io_service_)
      36                 :            :     {};
      37                 :            :     /// \brief The destructor.
      38                 :        194 :     ~IOServiceImpl() {};
      39                 :            :     //@}
      40                 :            : 
      41                 :            :     /// \brief Start the underlying event loop.
      42                 :            :     ///
      43                 :            :     /// This method does not return control to the caller until
      44                 :            :     /// the \c stop() method is called via some handler.
      45                 :         52 :     void run() { io_service_.run(); };
      46                 :            : 
      47                 :            :     /// \brief Run the underlying event loop for a single event.
      48                 :            :     ///
      49                 :            :     /// This method return control to the caller as soon as the
      50                 :            :     /// first handler has completed.  (If no handlers are ready when
      51                 :            :     /// it is run, it will block until one is.)
      52                 :         11 :     void run_one() { io_service_.run_one();} ;
      53                 :            : 
      54                 :            :     /// \brief Stop the underlying event loop.
      55                 :            :     ///
      56                 :            :     /// This will return the control to the caller of the \c run() method.
      57                 :            :     void stop() { io_service_.stop();} ;
      58                 :            : 
      59                 :            :     /// \brief Return the native \c io_service object used in this wrapper.
      60                 :            :     ///
      61                 :            :     /// This is a short term work around to support other BIND 10 modules
      62                 :            :     /// that share the same \c io_service with the authoritative server.
      63                 :            :     /// It will eventually be removed once the wrapper interface is
      64                 :            :     /// generalized.
      65                 :            :     asio::io_service& get_io_service() { return io_service_; };
      66                 :            : private:
      67                 :            :     asio::io_service io_service_;
      68                 :            :     asio::io_service::work work_;
      69                 :            : };
      70                 :            : 
      71                 :        194 : IOService::IOService() {
      72                 :        194 :     io_impl_ = new IOServiceImpl();
      73                 :        194 : }
      74                 :            : 
      75                 :        194 : IOService::~IOService() {
      76         [ +  - ]:        388 :     delete io_impl_;
      77                 :        194 : }
      78                 :            : 
      79                 :            : void
      80                 :         52 : IOService::run() {
      81                 :         52 :     io_impl_->run();
      82                 :         52 : }
      83                 :            : 
      84                 :            : void
      85                 :         11 : IOService::run_one() {
      86                 :         11 :     io_impl_->run_one();
      87                 :         11 : }
      88                 :            : 
      89                 :            : void
      90                 :         52 : IOService::stop() {
      91                 :         52 :     io_impl_->stop();
      92                 :         52 : }
      93                 :            : 
      94                 :            : asio::io_service&
      95                 :        497 : IOService::get_io_service() {
      96                 :        497 :     return (io_impl_->get_io_service());
      97                 :            : }
      98                 :            : 
      99                 :            : } // namespace asiolink
     100 [ +  - ][ +  - ]:         30 : } // namespace isc

Generated by: LCOV version 1.9