API symbolsfutures
Copy
Future
- class tensorplay.futures.Future(*, _completer: Callable[[], Any] | None = None)[source]
Holder for an asynchronous result (torch parity subset).
Example:
>>> fut = tp.futures.Future() >>> fut.set_result(1) >>> fut.value() 1 >>> chained = other.then(lambda f: f.value()[0]) >>> chained.value() tensor(...)
- add_done_callback(callback: Callable[[Future], Any]) None[source]
Appends a callback run when this future completes.
- then(callback: Callable[[Future], Any]) Future[source]
Adds a callback mapped over this future; returns the new future.
The callback receives this future and its return value becomes the derived future’s result (torch
Future.thencontract).
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?
