source: mainline/uspace/lib/cpp/include/__bits/thread/future_common.hpp@ c6f23a7

Last change on this file since c6f23a7 was b57ba05, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in C++ files

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2019 Jaroslav Jindrak
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef LIBCPP_BITS_THREAD_FUTURE_COMMON
8#define LIBCPP_BITS_THREAD_FUTURE_COMMON
9
10#include <__bits/aux.hpp>
11#include <system_error>
12#include <stdexcept>
13
14namespace std
15{
16 /**
17 * 30.6, futures:
18 */
19
20 enum class future_errc
21 { // The 5001 start is to not collide with system_error's codes.
22 broken_promise = 5001,
23 future_already_retrieved,
24 promise_already_satisfied,
25 no_state
26 };
27
28 enum class future_status
29 {
30 ready,
31 timeout,
32 deferred
33 };
34
35 /**
36 * 30.6.2, error handling:
37 */
38
39 template<>
40 struct is_error_code_enum<future_errc>: true_type
41 { /* DUMMY BODY */ };
42
43 error_code make_error_code(future_errc) noexcept;
44 error_condition make_error_condition(future_errc) noexcept;
45
46 const error_category& future_category() noexcept;
47
48 /**
49 * 30.6.3, class future_error:
50 */
51
52 class future_error: public logic_error
53 {
54 public:
55 future_error(error_code ec);
56
57 const error_code& code() const noexcept;
58 const char* what() const noexcept;
59
60 private:
61 error_code code_;
62 };
63
64 namespace aux
65 {
66 /**
67 * Auxilliary metafunctions that let us avoid
68 * specializations in some cases. They represent
69 * the inner stored type and the return type of
70 * the get() member function, respectively.
71 */
72
73 template<class T>
74 struct future_inner: aux::type_is<T>
75 { /* DUMMY BODY */ };
76
77 template<class T>
78 struct future_inner<T&>: aux::type_is<T*>
79 { /* DUMMY BODY */ };
80
81 template<class T>
82 using future_inner_t = typename future_inner<T>::type;
83
84 template<class T>
85 struct future_return_shared: aux::type_is<const T&>
86 { /* DUMMY BODY */ };
87
88 template<class T>
89 struct future_return_shared<T&>: aux::type_is<T&>
90 { /* DUMMY BODY */ };
91
92 template<>
93 struct future_return_shared<void>: aux::type_is<void>
94 { /* DUMMY BODY */ };
95
96 template<class T>
97 using future_return_shared_t = typename future_return_shared<T>::type;
98 }
99}
100
101#endif
Note: See TracBrowser for help on using the repository browser.