Skip to content

Commit 07c77b0

Browse files
committed
common/async: Add concepts.h
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 <[email protected]>
1 parent 26ef486 commit 07c77b0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/common/async/concepts.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2+
// vim: ts=8 sw=2 smarttab ft=cpp
3+
4+
/*
5+
* Ceph - scalable distributed file system
6+
*
7+
* Copyright contributors to the Ceph project
8+
*
9+
* This is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License version 2.1, as published by the Free Software
12+
* Foundation. See file COPYING.
13+
*
14+
*/
15+
16+
#pragma once
17+
18+
#include <type_traits>
19+
20+
#include <boost/asio/disposition.hpp>
21+
#include <boost/asio/execution_context.hpp>
22+
23+
/// \file common/async/concepts
24+
///
25+
/// \brief Because Asio needs to implement more concepts
26+
27+
namespace ceph::async {
28+
29+
/// The constraint from functions taking an ExecutionContext packed
30+
/// into a concept.
31+
template<typename ExecutionContext>
32+
concept execution_context =
33+
std::is_convertible_v<ExecutionContext&,
34+
boost::asio::execution_context&>;
35+
36+
/// A concept for Asio 'disposition's, a generalization of error
37+
/// codes/exception pointers, etc.
38+
template<typename T>
39+
concept disposition =
40+
boost::asio::is_disposition_v<T>;
41+
}

0 commit comments

Comments
 (0)