/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. #ifndef BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP
  11. #define BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/push_options.hpp>
  16. #include <boost/asio/detail/op_queue.hpp>
  17. #include <boost/asio/detail/task_io_service_fwd.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace detail {
  21. // Base class for all operations. A function pointer is used instead of virtual
  22. // functions to avoid the associated overhead.
  23. template <typename Task>
  24. class task_io_service_operation
  25. {
  26. public:
  27. void complete(task_io_service<Task>& owner)
  28. {
  29. func_(&owner, this, boost::system::error_code(), 0);
  30. }
  31. void destroy()
  32. {
  33. func_(0, this, boost::system::error_code(), 0);
  34. }
  35. protected:
  36. typedef void (*func_type)(task_io_service<Task>*,
  37. task_io_service_operation*, boost::system::error_code, std::size_t);
  38. task_io_service_operation(func_type func)
  39. : next_(0),
  40. func_(func)
  41. {
  42. }
  43. // Prevents deletion through this type.
  44. ~task_io_service_operation()
  45. {
  46. }
  47. private:
  48. friend class op_queue_access;
  49. task_io_service_operation* next_;
  50. func_type func_;
  51. };
  52. } // namespace detail
  53. } // namespace asio
  54. } // namespace boost
  55. #include <boost/system/error_code.hpp>
  56. #include <boost/asio/detail/pop_options.hpp>
  57. #endif // BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP