docs.rs failed to build sgx_core_futures-1.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Libcore wrapper allowing async/await
# Usage
Put the following in your Cargo.toml:
```toml
[dependencies]
core = { package = "sgx_core_futures", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
```
# Why
Currently, async/await is not usable from libcore. Attempting to call .await
from a `no_std` crate will yield the following error:
```norun
error[E0433]: failed to resolve: could not find `poll_with_tls_context` in `future`
error[E0433]: failed to resolve: could not find `from_generator` in `future`
```
This is due to await lowering to some code calling the functions
`::core::futures::poll_with_tls_context` and `::core::futures::from_generator`
in order to setup a per-thread context containing the current task. Those
functions, however, do not exist. The equivalent functions are defined in
libstd. They set up a thread-local variable which contains the current task
being executed. When polling a future, this task will get retrieved in order
to call the future's `poll` function.
As mentioned, the libstd version of those functions use a thread-local
variable, which is only supported in rust's libstd through the
`thread_local!` macro - which doesn't exist in libcore. There is, however,
an alternative: The (unstable) `#[thread_local]` attribute, which uses ELF
TLS. Note that ELF TLS is not portable to all targets - it needs to be
supported by the OS, the loader, etc...
Here's a small example of the thread_local attribute in action:
```rust
#![feature(thread_local)]
use core::cell::Cell;
#[thread_local]
static TLS_CX: CellPlease check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.