Description
Hey all!
I'm looking to use the futures
crate on an embedded target with no CAS atomics (specifically thumbv6m-none-eabi
), and currently I am required to use the following features which require nightly:
[dependencies.futures]
version = "0.3.14"
default-features = false
features = [ "cfg-target-has-atomic", "unstable" ]
Without these flags, I get the following errors:
error[E0599]: no method named `compare_exchange` found for struct `AtomicUsize` in the current scope
--> /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.14/src/task/__internal/atomic_waker.rs:264:14
|
264 | .compare_exchange(WAITING, REGISTERING, Acquire, Acquire)
| ^^^^^^^^^^^^^^^^ method not found in `AtomicUsize`
error[E0599]: no method named `compare_exchange` found for struct `AtomicUsize` in the current scope
--> /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.14/src/task/__internal/atomic_waker.rs:282:42
|
282 | let res = self.state.compare_exchange(
| ^^^^^^^^^^^^^^^^ method not found in `AtomicUsize`
error[E0599]: no method named `swap` found for struct `AtomicUsize` in the current scope
--> /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.14/src/task/__internal/atomic_waker.rs:308:40
|
308 | ... self.state.swap(WAITING, AcqRel);
| ^^^^ method not found in `AtomicUsize`
error[E0599]: no method named `fetch_or` found for struct `AtomicUsize` in the current scope
--> /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.14/src/task/__internal/atomic_waker.rs:375:26
|
375 | match self.state.fetch_or(WAKING, AcqRel) {
| ^^^^^^^^ method not found in `AtomicUsize`
error[E0599]: no method named `fetch_and` found for struct `AtomicUsize` in the current scope
--> /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.14/src/task/__internal/atomic_waker.rs:381:28
|
381 | self.state.fetch_and(!WAKING, Release);
| ^^^^^^^^^ method not found in `AtomicUsize`
error: aborting due to 5 previous errors
This is due to the target atomic configuration flag currently being nightly-only. Unfortunately, this means that the library that I am working on would also be restricted to nightly-only, or I'd have to fork the futures
crate, which would be a compatibility problem.
Would you be open to adding a disable-cas-atomics
feature that ALWAYS disables these features (without checking the target cfg)? I believe this should be a straightfoward, but somewhat verbose PR, so I wanted check before working on it.
CC @Dirbaio, who has also run into this for embedded async support.
Thanks!