aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asio/system_executor.hpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-08-06 10:35:22 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-08-06 10:35:22 +0200
commite95946831f8ef53d29590735a2df661385edb008 (patch)
treee179b6beed4a5a0dd108f078a529ae9f8107ed8e /lib/asio/system_executor.hpp
parent8bc01ff60629d9096f4b57cfb574ace672a6ef0e (diff)
downloaddabmod-e95946831f8ef53d29590735a2df661385edb008.tar.gz
dabmod-e95946831f8ef53d29590735a2df661385edb008.tar.bz2
dabmod-e95946831f8ef53d29590735a2df661385edb008.zip
Replace boost by the standalone asio library
Diffstat (limited to 'lib/asio/system_executor.hpp')
-rw-r--r--lib/asio/system_executor.hpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/lib/asio/system_executor.hpp b/lib/asio/system_executor.hpp
new file mode 100644
index 0000000..b588a21
--- /dev/null
+++ b/lib/asio/system_executor.hpp
@@ -0,0 +1,129 @@
+//
+// system_executor.hpp
+// ~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef ASIO_SYSTEM_EXECUTOR_HPP
+#define ASIO_SYSTEM_EXECUTOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include "asio/detail/config.hpp"
+
+#include "asio/detail/push_options.hpp"
+
+namespace asio {
+
+class system_context;
+
+/// An executor that uses arbitrary threads.
+/**
+ * The system executor represents an execution context where functions are
+ * permitted to run on arbitrary threads. The post() and defer() functions
+ * schedule the function to run on an unspecified system thread pool, and
+ * dispatch() invokes the function immediately.
+ */
+class system_executor
+{
+public:
+ /// Obtain the underlying execution context.
+ system_context& context() const ASIO_NOEXCEPT;
+
+ /// Inform the executor that it has some outstanding work to do.
+ /**
+ * For the system executor, this is a no-op.
+ */
+ void on_work_started() const ASIO_NOEXCEPT
+ {
+ }
+
+ /// Inform the executor that some work is no longer outstanding.
+ /**
+ * For the system executor, this is a no-op.
+ */
+ void on_work_finished() const ASIO_NOEXCEPT
+ {
+ }
+
+ /// Request the system executor to invoke the given function object.
+ /**
+ * This function is used to ask the executor to execute the given function
+ * object. The function object will always be executed inside this function.
+ *
+ * @param f The function object to be called. The executor will make
+ * a copy of the handler object as required. The function signature of the
+ * function object must be: @code void function(); @endcode
+ *
+ * @param a An allocator that may be used by the executor to allocate the
+ * internal storage needed for function invocation.
+ */
+ template <typename Function, typename Allocator>
+ void dispatch(ASIO_MOVE_ARG(Function) f, const Allocator& a) const;
+
+ /// Request the system executor to invoke the given function object.
+ /**
+ * This function is used to ask the executor to execute the given function
+ * object. The function object will never be executed inside this function.
+ * Instead, it will be scheduled to run on an unspecified system thread pool.
+ *
+ * @param f The function object to be called. The executor will make
+ * a copy of the handler object as required. The function signature of the
+ * function object must be: @code void function(); @endcode
+ *
+ * @param a An allocator that may be used by the executor to allocate the
+ * internal storage needed for function invocation.
+ */
+ template <typename Function, typename Allocator>
+ void post(ASIO_MOVE_ARG(Function) f, const Allocator& a) const;
+
+ /// Request the system executor to invoke the given function object.
+ /**
+ * This function is used to ask the executor to execute the given function
+ * object. The function object will never be executed inside this function.
+ * Instead, it will be scheduled to run on an unspecified system thread pool.
+ *
+ * @param f The function object to be called. The executor will make
+ * a copy of the handler object as required. The function signature of the
+ * function object must be: @code void function(); @endcode
+ *
+ * @param a An allocator that may be used by the executor to allocate the
+ * internal storage needed for function invocation.
+ */
+ template <typename Function, typename Allocator>
+ void defer(ASIO_MOVE_ARG(Function) f, const Allocator& a) const;
+
+ /// Compare two executors for equality.
+ /**
+ * System executors always compare equal.
+ */
+ friend bool operator==(const system_executor&,
+ const system_executor&) ASIO_NOEXCEPT
+ {
+ return true;
+ }
+
+ /// Compare two executors for inequality.
+ /**
+ * System executors always compare equal.
+ */
+ friend bool operator!=(const system_executor&,
+ const system_executor&) ASIO_NOEXCEPT
+ {
+ return false;
+ }
+};
+
+} // namespace asio
+
+#include "asio/detail/pop_options.hpp"
+
+#include "asio/impl/system_executor.hpp"
+
+#endif // ASIO_SYSTEM_EXECUTOR_HPP