Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add use_atomic feature #627

Closed
wants to merge 2 commits into from
Closed

Conversation

ealasu
Copy link

@ealasu ealasu commented Oct 29, 2017

Fixes #622

@alexcrichton
Copy link
Member

Thanks for the PR! I'm pretty wary about this though as it basically turns off most of the library. I don't think we're quite ready to have a world without atomics and a futures crate right now, too much of the low level internals require atomics.

@carllerche
Copy link
Member

What platform does not include atomics?

@ealasu
Copy link
Author

ealasu commented Oct 30, 2017

@carllerche thumbv6m-none-eabi, which is used for microcontrollers based on ARM Cortex M0, M0+, and M1. The specific board I'm trying to use is an Arduino Zero.
Also see rust-lang/compiler-builtins#114 for basically the same issue in another crate.

@alexcrichton
Copy link
Member

@ealasu I don't think we're going to be able to take this PR at this time. Most of this library is engineered around the existence of the task system which is itself engineered around the existence of atomics. It's sort of unclear how we would implement the library beyond the literal Future trait itself without the task system and atomics.

Is it critical that the futures crate as-is is usable in your context? I don't think you'd be able to use anything that depends on the futures crate because it all assumes a task system?

@ealasu
Copy link
Author

ealasu commented Nov 1, 2017

@alexcrichton I've found the Future & Stream traits quite useful on their own, as an API for writing portable asynchronous code.
For example, in one project I'm implementing a stream/sink transform to add a reliable communication layer over a serial port:
https://github.com/ealasu/rust-keyboard/blob/master/framed/src/stream.rs
https://github.com/ealasu/rust-keyboard/blob/master/framed/src/sink.rs
Since it only depends on the Stream & Sink traits, the same code can run on both an embedded Cortex-M0 system and on a full-fledged Linux system. On Linux I'll use Tokio for the event loop, while on the embedded system I'll simply poll the stream/sink in a loop:

loop {
    while let Async::Ready(frame) = frame_stream.poll().unwrap() {
        // do stuff with frame
    }
    // do other stuff
}

If the futures crate didn't support the Cortex-M0 platform, it would be more difficult to write asynchronous code like this that supported both Cortex-M0 and tokio.

@alexcrichton
Copy link
Member

Oh yeah I don't disagree that they can be useful abstractions, but my point is that in the case where you don't have a task system or any atomics at all I think the utility for a "shared abstraction" is greatly reduced, and it's effectively equivalent to having a local vendored trait at that point.

@ealasu
Copy link
Author

ealasu commented Nov 8, 2017

There are some useful crates that depend on futures but don't need the task system, like futures-await.

@alexcrichton
Copy link
Member

@ealasu sure yeah but in general this is something that's going to be very difficult to maintain over time. Most maintainers are pretty used to a std/core split but AFAIK few are used to atomic/no atomic splits. I, for example, have no experience maintaining a no-atomic platform.

@alexcrichton
Copy link
Member

Ok I'm going to close this for now as I don't think we'll get very far in futures without atomics, but we can of course continue discussion in the issue tracker if you'd like!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants