ORIGINAL
|
Represents a sharable asynchronous result. More...
#include <async.h>
Public Member Functions | |
sharedFuture (const sharedFuture &)=default | |
sharedFuture & | operator= (const sharedFuture &)=default |
sharedFuture (sharedFuture &&)=default | |
sharedFuture & | operator= (sharedFuture &&)=default |
bool | valid () const noexcept override |
Checks if the shared future is valid (has an associated async wrapper) | |
TYPE | result () const |
Gets the result value (blocks until ready) | |
strongPtr< const TYPE > | strongPointer () const |
Gets a strong pointer to the result value. | |
bool | ready () const override |
Checks if the result is ready. | |
std::exception_ptr | exception () const noexcept override |
Gets the exception if computation failed. | |
bool | operator== (const sharedFuture &other) const noexcept |
Equality comparison operator. | |
bool | operator!= (const sharedFuture &other) const noexcept |
Inequality comparison operator. | |
void | wait () const override |
Waits until the result becomes ready. | |
bool | waitFor (time::duration timeout) const override |
Waits for the result with a timeout. | |
u_integer | toHash () const noexcept override |
Generates a hash value for the shared future. | |
bool | equals (const sharedFuture &other) const noexcept override |
Checks if two shared futures are equal. | |
![]() | |
virtual bool | equals (const sharedFuture< TYPE > &other) const noexcept |
Compares two objects for equality. | |
virtual | ~hashable ()=0 |
Virtual destructor. | |
Friends | |
class | async |
Represents a sharable asynchronous result.
TYPE | The result type of the computation |
Unlike future
, sharedFuture
can be copied and safely stored in multiple places. All copies refer to the same asynchronous result, making it suitable for scenarios where results are needed by multiple consumers.
|
overridenoexcept |
Checks if two shared futures are equal.
other | The other shared future to compare with |
|
overridevirtualnoexcept |
Gets the exception if computation failed.
Implements original::async::futureBase.
|
noexcept |
Inequality comparison operator.
other | The other shared future to compare with |
|
noexcept |
Equality comparison operator.
other | The other shared future to compare with |
|
overridevirtual |
Checks if the result is ready.
Implements original::async::futureBase.
TYPE original::async::sharedFuture< TYPE >::result | ( | ) | const |
Gets the result value (blocks until ready)
std::exception | if the computation threw an exception |
original::strongPtr< const TYPE > original::async::sharedFuture< TYPE >::strongPointer | ( | ) | const |
Gets a strong pointer to the result value.
Returns a strong reference pointer to the asynchronous result, extending the lifetime of the referenced object and avoiding dangling references. The pointer approach avoids unnecessary copying
sysError | if the shared future is invalid or not ready |
std::exception | if the computation threw an exception |
|
overridevirtualnoexcept |
Generates a hash value for the shared future.
Reimplemented from original::hashable< sharedFuture< TYPE > >.
|
overridevirtualnoexcept |
Checks if the shared future is valid (has an associated async wrapper)
Implements original::async::futureBase.
|
overridevirtual |
Waits until the result becomes ready.
Implements original::async::futureBase.
|
overridevirtual |
Waits for the result with a timeout.
timeout | Maximum time to wait |
Implements original::async::futureBase.