]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/async: Add concepts.h
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 18 Apr 2025 00:08:36 +0000 (20:08 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Thu, 7 Aug 2025 19:00:00 +0000 (15:00 -0400)
Asio does not have nearly as many actual explicit concepts one can use
as one might like.

And there's no reason we might not want our own asynchrony-related concepts.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
(cherry picked from commit 07c77b0c886799ec0cfa7419ecdb72cb242f6af7)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/common/async/concepts.h [new file with mode: 0644]

diff --git a/src/common/async/concepts.h b/src/common/async/concepts.h
new file mode 100644 (file)
index 0000000..ad960b6
--- /dev/null
@@ -0,0 +1,41 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab ft=cpp
+
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright contributors to the Ceph project
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#pragma once
+
+#include <type_traits>
+
+#include <boost/asio/disposition.hpp>
+#include <boost/asio/execution_context.hpp>
+
+/// \file common/async/concepts
+///
+/// \brief Because Asio needs to implement more concepts
+
+namespace ceph::async {
+
+/// The constraint from functions taking an ExecutionContext packed
+/// into a concept.
+template<typename ExecutionContext>
+concept execution_context =
+  std::is_convertible_v<ExecutionContext&,
+                        boost::asio::execution_context&>;
+
+/// A concept for Asio 'disposition's, a generalization of error
+/// codes/exception pointers, etc.
+template<typename T>
+concept disposition =
+  boost::asio::is_disposition_v<T>;
+}