Legion Runtime
Loading...
Searching...
No Matches
future.h
Go to the documentation of this file.
1/* Copyright 2026 Stanford University, NVIDIA Corporation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef __LEGION_FUTURE_H__
17#define __LEGION_FUTURE_H__
18
25
26namespace Legion {
27
28 //==========================================================================
29 // Future Value Classes
30 //==========================================================================
31
50 class Future : public Unserializable {
51 public:
52 Future(void);
53 Future(const Future& f);
54 Future(Future&& f) noexcept;
55 ~Future(void);
56 private:
57 Internal::FutureImpl* impl;
58 protected:
59 // Only the runtime should be allowed to make these
60 FRIEND_ALL_RUNTIME_CLASSES
61 explicit Future(Internal::FutureImpl* impl);
62 public:
63 inline bool exists(void) const { return (impl != nullptr); }
64 inline bool operator==(const Future& f) const { return impl == f.impl; }
65 inline bool operator<(const Future& f) const { return impl < f.impl; }
66 Future& operator=(const Future& f);
67 Future& operator=(Future&& f) noexcept;
68 std::size_t hash(void) const;
69 public:
78 template<typename T>
79 inline T get_result(
80 bool silence_warnings = false,
81 const char* warning_string = nullptr) const;
88 bool silence_warnings = false,
89 const char* warning_string = nullptr) const;
102 bool block = false, bool silence_warnings = false,
103 const char* warning_string = nullptr) const;
111 bool is_ready(bool subscribe = false) const;
112 public:
127 template<typename T, PrivilegeMode PM = LEGION_READ_ONLY>
128 Span<T, PM> get_span(
129 Memory::Kind memory, bool silence_warnings = false,
130 const char* warning_string = nullptr) const;
131
145 const void* get_buffer(
146 Memory::Kind memory, size_t* extent_in_bytes = nullptr,
147 bool check_extent = false, bool silence_warnings = false,
148 const char* warning_string = nullptr) const;
149
158 std::set<Memory>& memories, bool silence_warnings = false,
159 const char* warning_string = nullptr) const;
160
174 template<typename T>
175 LEGION_DEPRECATED("Use 'Future::get_span' instead")
176 inline const T& get_reference(
177 bool silence_warnings = false,
178 const char* warning_string = nullptr) const;
189 LEGION_DEPRECATED("Use 'Future::get_buffer' instead")
190 inline const void* get_untyped_pointer(
191 bool silence_warnings = false,
192 const char* warning_string = nullptr) const;
193
197 size_t get_untyped_size(void) const;
198
207 const void* get_metadata(size_t* size = nullptr) const;
208 public:
209 // These methods provide partial support the C++ future interface
210 template<typename T>
211 inline T get(void);
212
213 inline bool valid(void) const;
214
215 inline void wait(void) const;
216 public:
222 template<typename T>
223 LEGION_DEPRECATED("Use the version without a runtime pointer argument")
224 static inline Future from_value(Runtime* rt, const T& value);
225 template<typename T>
226 static inline Future from_value(const T& value);
233 const Domain& d, bool take_ownership, const char* provenance = nullptr,
234 bool shard_local = false);
235
240 LEGION_DEPRECATED("Use the version without a runtime pointer argument")
242 Runtime* rt, const void* buffer, size_t bytes,
243 bool take_ownership = false);
245 const void* buffer, size_t bytes, bool take_ownership = false,
246 const char* provenance = nullptr, bool shard_local = false);
247 static Future from_value(
248 const void* buffer, size_t bytes, bool owned,
249 const Realm::ExternalInstanceResource& resource,
250 void (*freefunc)(const Realm::ExternalInstanceResource&) = nullptr,
251 const char* provenance = nullptr, bool shard_local = false);
252 private:
253 // This should only be available for accessor classes
254 template<PrivilegeMode, typename, int, typename, typename, bool>
255 friend class FieldAccessor;
256 Realm::RegionInstance get_instance(
257 Memory::Kind kind, size_t field_size, bool check_field_size,
258 const char* warning_string, bool silence_warnings) const;
259 void report_incompatible_accessor(
260 const char* accessor_kind, Realm::RegionInstance instance) const;
261 };
262
263} // namespace Legion
264
265#include "legion/api/future.inl"
266
267#endif // __LEGION_FUTURE_H__
Definition geometry.h:159
Definition accessors.h:76
Definition future.h:50
void get_memories(std::set< Memory > &memories, bool silence_warnings=false, const char *warning_string=nullptr) const
static Future from_untyped_pointer(Runtime *rt, const void *buffer, size_t bytes, bool take_ownership=false)
static Future from_domain(const Domain &d, bool take_ownership, const char *provenance=nullptr, bool shard_local=false)
const T & get_reference(bool silence_warnings=false, const char *warning_string=nullptr) const
size_t get_untyped_size(void) const
const void * get_metadata(size_t *size=nullptr) const
static Future from_value(Runtime *rt, const T &value)
const void * get_untyped_pointer(bool silence_warnings=false, const char *warning_string=nullptr) const
Span< T, PM > get_span(Memory::Kind memory, bool silence_warnings=false, const char *warning_string=nullptr) const
T get_result(bool silence_warnings=false, const char *warning_string=nullptr) const
const void * get_buffer(Memory::Kind memory, size_t *extent_in_bytes=nullptr, bool check_extent=false, bool silence_warnings=false, const char *warning_string=nullptr) const
bool is_ready(bool subscribe=false) const
bool is_empty(bool block=false, bool silence_warnings=false, const char *warning_string=nullptr) const
void get_void_result(bool silence_warnings=false, const char *warning_string=nullptr) const
Definition runtime.h:108
Definition types.h:343
Definition accessors.h:29