PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/boost/asio/detail/task_io_service_operation.hpp

http://pythonocc.googlecode.com/
C++ Header | 71 lines | 45 code | 14 blank | 12 comment | 1 complexity | cd92d66ef2e27e2aa17d581eb654d813 MD5 | raw file
 1//
 2// task_io_service_operation.hpp
 3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4//
 5// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 6//
 7// Distributed under the Boost Software License, Version 1.0. (See accompanying
 8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 9//
10
11#ifndef BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP
12#define BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/push_options.hpp>
19
20#include <boost/asio/detail/op_queue.hpp>
21#include <boost/asio/detail/task_io_service_fwd.hpp>
22
23namespace boost {
24namespace asio {
25namespace detail {
26
27// Base class for all operations. A function pointer is used instead of virtual
28// functions to avoid the associated overhead.
29template <typename Task>
30class task_io_service_operation
31{
32public:
33  void complete(task_io_service<Task>& owner)
34  {
35    func_(&owner, this, boost::system::error_code(), 0);
36  }
37
38  void destroy()
39  {
40    func_(0, this, boost::system::error_code(), 0);
41  }
42
43protected:
44  typedef void (*func_type)(task_io_service<Task>*,
45      task_io_service_operation*, boost::system::error_code, std::size_t);
46
47  task_io_service_operation(func_type func)
48    : next_(0),
49      func_(func)
50  {
51  }
52
53  // Prevents deletion through this type.
54  ~task_io_service_operation()
55  {
56  }
57
58private:
59  friend class op_queue_access;
60  task_io_service_operation* next_;
61  func_type func_;
62};
63
64} // namespace detail
65} // namespace asio
66} // namespace boost
67
68#include <boost/system/error_code.hpp>
69#include <boost/asio/detail/pop_options.hpp>
70
71#endif // BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP