futures-rs icon indicating copy to clipboard operation
futures-rs copied to clipboard

Merge futures-util and futures-executor to main futures crate

Open taiki-e opened this issue 4 years ago • 3 comments

I would propose to merge these utility crates to the main futures crate. There are some reasons:

  • futures and futures-util are almost the same except that futures provide executors and channels. Also, both modules (executor and channel) seem to be relatively easy to make optional.
  • Most of the compile time for futures seems due to futures-util, and the compile time reduction by splitting the crate doesn't seem to work very well.
  • Since futures-executor also depends on futures-util, it doesn't seem to have much compile time advantage even if used individually.
  • As said in https://github.com/rust-lang/futures-rs/issues/1875#issuecomment-639895854, if futures and futures-util are different crates, it seems impossible to add optional features to futures per module. (I don't plan to add a "util" feature that enables the utility itself, but I would like to add features to enable per module in the next major version.)

futures-channel is also a "utility crate", but it's almost independent, so I'm not sure if merging it is really preferable.

taiki-e avatar Dec 22 '20 15:12 taiki-e

Sounds good to me assuming they're feature gated.

Nemo157 avatar Dec 22 '20 19:12 Nemo157

futures-channel is also a "utility crate", but it's almost independent, so I'm not sure if merging it is really preferable.

Given that futures-channel currently depends on futures-core's internal API, it probably makes sense to merge futures-channel into futures as well. This also allows AtomicWaker to move from futures-core to futures.

assuming they're feature gated.

For now, I'm considering adding the following features:

  • channel
    • enable channel module
  • executor
    • enable executor module
  • future-util (or just future)
    • enable utilities in future module
    • Future trait is available regardless of whether the feature is enabled.
  • io
    • enable io module
  • lock
    • enable lock module
  • sink
    • enable sink module
  • stream-util (or just stream)
    • enable utilities in stream module
    • Stream trait is available regardless of whether the feature is enabled.
  • task-util (or just task)
    • enable utilities in task module
    • Poll, Context, Waker etc. are available regardless of whether the feature is enabled.
    • (I haven't decided how to handle the spawn trait...)

(I'll open a new issue about this later.)

taiki-e avatar Jan 01 '21 05:01 taiki-e

To make backporting to 0.3 easier, I will block this for now.

taiki-e avatar May 06 '21 10:05 taiki-e