Realistic 3D camera system
3D camera system components
io_service.hpp
Go to the documentation of this file.
1 //
2 // io_service.hpp
3 // ~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 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 ASIO_IO_SERVICE_HPP
12 #define ASIO_IO_SERVICE_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 #include <cstddef>
20 #include <stdexcept>
21 #include <typeinfo>
22 #include "asio/async_result.hpp"
25 #include "asio/error_code.hpp"
26 
27 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
29 #elif defined(__sun) || defined(__QNX__) || defined(__hpux) || defined(_AIX) \
30  || defined(__osf__)
32 #endif
33 
35 
36 namespace asio {
37 
38 class io_service;
39 template <typename Service> Service& use_service(io_service& ios);
40 template <typename Service> void add_service(io_service& ios, Service* svc);
41 template <typename Service> bool has_service(io_service& ios);
42 
43 namespace detail {
44 #if defined(ASIO_HAS_IOCP)
45  typedef class win_iocp_io_service io_service_impl;
46  class win_iocp_overlapped_ptr;
47 #else
49 #endif
50  class service_registry;
51 } // namespace detail
52 
54 
185  : private noncopyable
186 {
187 private:
188  typedef detail::io_service_impl impl_type;
189 #if defined(ASIO_HAS_IOCP)
190  friend class detail::win_iocp_overlapped_ptr;
191 #endif
192 
193 public:
194  class work;
195  friend class work;
196 
197  class id;
198 
199  class service;
200 
201  class strand;
202 
205 
207 
213  ASIO_DECL explicit io_service(std::size_t concurrency_hint);
214 
216 
248 
250 
275  ASIO_DECL std::size_t run();
276 
278 
303  ASIO_DECL std::size_t run(asio::error_code& ec);
304 
307 
319  ASIO_DECL std::size_t run_one();
320 
323 
335  ASIO_DECL std::size_t run_one(asio::error_code& ec);
336 
339 
347  ASIO_DECL std::size_t poll();
348 
351 
359  ASIO_DECL std::size_t poll(asio::error_code& ec);
360 
363 
371  ASIO_DECL std::size_t poll_one();
372 
375 
383  ASIO_DECL std::size_t poll_one(asio::error_code& ec);
384 
386 
392  ASIO_DECL void stop();
393 
395 
404  ASIO_DECL bool stopped() const;
405 
407 
417  ASIO_DECL void reset();
418 
420 
440  template <typename CompletionHandler>
441  ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
442  dispatch(ASIO_MOVE_ARG(CompletionHandler) handler);
443 
445 
466  template <typename CompletionHandler>
467  ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
468  post(ASIO_MOVE_ARG(CompletionHandler) handler);
469 
472 
492  template <typename Handler>
493 #if defined(GENERATING_DOCUMENTATION)
494  unspecified
495 #else
497 #endif
498  wrap(Handler handler);
499 
502  {
505 
508 
510  fork_child
511  };
512 
514 
553  ASIO_DECL void notify_fork(asio::io_service::fork_event event);
554 
556 
566  template <typename Service>
567  friend Service& use_service(io_service& ios);
568 
570 
586  template <typename Service>
587  friend void add_service(io_service& ios, Service* svc);
588 
590 
598  template <typename Service>
599  friend bool has_service(io_service& ios);
600 
601 private:
602 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
603  detail::winsock_init<> init_;
604 #elif defined(__sun) || defined(__QNX__) || defined(__hpux) || defined(_AIX) \
605  || defined(__osf__)
606  detail::signal_init<> init_;
607 #endif
608 
609  // The service registry.
610  asio::detail::service_registry* service_registry_;
611 
612  // The implementation.
613  impl_type& impl_;
614 };
615 
617 
627 {
628 public:
630 
635  explicit work(asio::io_service& io_service);
636 
638 
643  work(const work& other);
644 
646 
651  ~work();
652 
654  asio::io_service& get_io_service();
655 
656 private:
657  // Prevent assignment.
658  void operator=(const work& other);
659 
660  // The io_service implementation.
661  detail::io_service_impl& io_service_impl_;
662 };
663 
666  : private noncopyable
667 {
668 public:
670  id() {}
671 };
672 
675  : private noncopyable
676 {
677 public:
679  asio::io_service& get_io_service();
680 
681 protected:
683 
687 
689  ASIO_DECL virtual ~service();
690 
691 private:
693  virtual void shutdown_service() = 0;
694 
697 
701  ASIO_DECL virtual void fork_service(
703 
705  struct key
706  {
707  key() : type_info_(0), id_(0) {}
708  const std::type_info* type_info_;
709  const asio::io_service::id* id_;
710  } key_;
711 
712  asio::io_service& owner_;
713  service* next_;
714 };
715 
718  : public std::logic_error
719 {
720 public:
722 };
723 
727  : public std::logic_error
728 {
729 public:
731 };
732 
733 namespace detail {
734 
735 // Special derived service id type to keep classes header-file only.
736 template <typename Type>
738  : public asio::io_service::id
739 {
740 };
741 
742 // Special service base class to keep classes header-file only.
743 template <typename Type>
746 {
747 public:
749 
750  // Constructor.
752  : asio::io_service::service(io_service)
753  {
754  }
755 };
756 
757 template <typename Type>
759 
760 } // namespace detail
761 } // namespace asio
762 
764 
765 #include "asio/impl/io_service.hpp"
766 #if defined(ASIO_HEADER_ONLY)
767 # include "asio/impl/io_service.ipp"
768 #endif // defined(ASIO_HEADER_ONLY)
769 
770 #endif // ASIO_IO_SERVICE_HPP
Notify the io_service that the process has forked and is the parent.
Definition: io_service.hpp:507
Class used to uniquely identify a service.
Definition: io_service.hpp:665
Provides core I/O functionality.
Definition: io_service.hpp:184
Class to inform the io_service when it has work to do.
Definition: io_service.hpp:626
Service & use_service(io_service &ios)
Definition: io_service.hpp:26
Provides serialised handler execution.
Definition: strand.hpp:85
class task_io_service io_service_impl
Definition: io_service.hpp:48
ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, void(asio::error_code, Iterator)) async_connect(basic_socket< Protocol
Notify the io_service that the process is about to fork.
Definition: io_service.hpp:504
Exception thrown when trying to add a duplicate service to an io_service.
Definition: io_service.hpp:717
void add_service(io_service &ios, Service *svc)
Definition: io_service.hpp:43
fork_event
Fork-related event notifications.
Definition: io_service.hpp:501
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
Definition: read.hpp:704
Class to represent an error code value.
Definition: error_code.hpp:80
#define ASIO_DECL
Definition: config.hpp:43
id()
Constructor.
Definition: io_service.hpp:670
static asio::detail::service_id< Type > id
Definition: io_service.hpp:748
bool has_service(io_service &ios)
Definition: io_service.hpp:53
null_event event
Definition: event.hpp:36
service_base(asio::io_service &io_service)
Definition: io_service.hpp:751
Base class for all io_service services.
Definition: io_service.hpp:674