Legion Runtime
Loading...
Searching...
No Matches
future.h
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
19#include "legion/api/physical_region.h"
20
21namespace Legion {
22
23 //==========================================================================
24 // Future Value Classes
25 //==========================================================================
26
45 class Future : public Unserializable {
46 public:
47 Future(void);
48 Future(const Future& f);
49 Future(Future&& f) noexcept;
50 ~Future(void);
51 private:
52 Internal::FutureImpl* impl;
53 protected:
54 // Only the runtime should be allowed to make these
55 FRIEND_ALL_RUNTIME_CLASSES
56 explicit Future(Internal::FutureImpl* impl);
57 public:
58 inline bool exists(void) const { return (impl != nullptr); }
59 inline bool operator==(const Future& f) const { return impl == f.impl; }
60 inline bool operator<(const Future& f) const { return impl < f.impl; }
61 Future& operator=(const Future& f);
62 Future& operator=(Future&& f) noexcept;
63 std::size_t hash(void) const;
64 public:
73 template<typename T>
74 inline T get_result(
75 bool silence_warnings = false,
76 const char* warning_string = nullptr) const;
83 bool silence_warnings = false,
84 const char* warning_string = nullptr) const;
97 bool block = false, bool silence_warnings = false,
98 const char* warning_string = nullptr) const;
106 bool is_ready(bool subscribe = false) const;
107 public:
122 template<typename T, PrivilegeMode PM = LEGION_READ_ONLY>
123 Span<T, PM> get_span(
124 Memory::Kind memory, bool silence_warnings = false,
125 const char* warning_string = nullptr) const;
126
140 const void* get_buffer(
141 Memory::Kind memory, size_t* extent_in_bytes = nullptr,
142 bool check_extent = false, bool silence_warnings = false,
143 const char* warning_string = nullptr) const;
144
153 std::set<Memory>& memories, bool silence_warnings = false,
154 const char* warning_string = nullptr) const;
155
169 template<typename T>
170 LEGION_DEPRECATED("Use 'Future::get_span' instead")
171 inline const T& get_reference(
172 bool silence_warnings = false,
173 const char* warning_string = nullptr) const;
184 LEGION_DEPRECATED("Use 'Future::get_buffer' instead")
185 inline const void* get_untyped_pointer(
186 bool silence_warnings = false,
187 const char* warning_string = nullptr) const;
188
192 size_t get_untyped_size(void) const;
193
202 const void* get_metadata(size_t* size = nullptr) const;
203 public:
204 // These methods provide partial support the C++ future interface
205 template<typename T>
206 inline T get(void);
207
208 inline bool valid(void) const;
209
210 inline void wait(void) const;
211 public:
217 template<typename T>
218 LEGION_DEPRECATED("Use the version without a runtime pointer argument")
219 static inline Future from_value(Runtime* rt, const T& value);
220 template<typename T>
221 static inline Future from_value(const T& value);
228 const Domain& d, bool take_ownership, const char* provenance = nullptr,
229 bool shard_local = false);
230
235 LEGION_DEPRECATED("Use the version without a runtime pointer argument")
237 Runtime* rt, const void* buffer, size_t bytes,
238 bool take_ownership = false);
240 const void* buffer, size_t bytes, bool take_ownership = false,
241 const char* provenance = nullptr, bool shard_local = false);
242 static Future from_value(
243 const void* buffer, size_t bytes, bool owned,
244 const Realm::ExternalInstanceResource& resource,
245 void (*freefunc)(const Realm::ExternalInstanceResource&) = nullptr,
246 const char* provenance = nullptr, bool shard_local = false);
247 private:
248 // This should only be available for accessor classes
249 template<PrivilegeMode, typename, int, typename, typename, bool>
250 friend class FieldAccessor;
251 Realm::RegionInstance get_instance(
252 Memory::Kind kind, size_t field_size, bool check_field_size,
253 const char* warning_string, bool silence_warnings) const;
254 void report_incompatible_accessor(
255 const char* accessor_kind, Realm::RegionInstance instance) const;
256 };
257
258} // namespace Legion
259
260#include "legion/api/future.inl"
261
262#endif // __LEGION_FUTURE_H__
Definition geometry.h:154
Definition accessors.h:71
Definition future.h:45
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:103
Definition types.h:334