Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

add a helper for running futures concurrently #541

Merged
merged 4 commits into from
Jan 15, 2021

Conversation

little-dude
Copy link
Contributor

This will allow clients to start sending multiple chunks concurrently.

FuturesUnordered
allows us to poll multiple futures, but if we want to really run them
concurrently we need to spawn them first. So this type is just a thin
wrapper around FuturesUnordered.

@little-dude little-dude force-pushed the concurrent_futures branch 2 times, most recently from 5ee9efe to 46ecb8f Compare October 1, 2020 08:53
@codecov
Copy link

codecov bot commented Oct 1, 2020

Codecov Report

Merging #541 (16ed2e9) into master (123b71b) will increase coverage by 0.09%.
The diff coverage is 92.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #541      +/-   ##
==========================================
+ Coverage   60.67%   60.76%   +0.09%     
==========================================
  Files          96       97       +1     
  Lines        4399     4412      +13     
==========================================
+ Hits         2669     2681      +12     
- Misses       1730     1731       +1     
Impacted Files Coverage Δ
rust/xaynet-sdk/src/utils/concurrent_futures.rs 92.30% <92.30%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f978039...16ed2e9. Read the comment docs.

@janpetschexain
Copy link
Contributor

janpetschexain commented Jan 14, 2021

rebased. we should probably move this to the e2e package later on (#568), i left a todo.

little-dude and others added 4 commits January 15, 2021 14:15
This will allow clients to start sending multiple chunks concurrently.

[`FuturesUnordered`](https://docs.rs/futures-util/0.3.5/futures_util/stream/futures_unordered/struct.FuturesUnordered.html)
allows us to poll multiple futures, but if we want to really run them
_concurrently_ we need to spawn them first. So this type is just a thin
wrapper around `FuturesUnordered`.
Copy link
Contributor

@Robert-Steiner Robert-Steiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janpetschexain thanks for the rebase 👍

@little-dude
Copy link
Contributor Author

What are you guys going to use this for? I forgot why I did that in the first place

@janpetschexain
Copy link
Contributor

What are you guys going to use this for? I forgot why I did that in the first place

@Robert-Steiner wants to use it for the e2e tests, but they are not mergeable yet. since we are cleaning up things for the next release, we want to merge this so it doesn't get lost.

@janpetschexain janpetschexain merged commit bb73e6d into master Jan 15, 2021
@janpetschexain janpetschexain deleted the concurrent_futures branch January 15, 2021 13:44
@little-dude
Copy link
Contributor Author

Forgot to mention why I didn't want to use FuturesUnordered or BufferUnordered: https://discord.com/channels/500028886025895936/500336333500448798/704402952235909200

@little-dude if you want futures to execute concurrently you may want to spawn anyway... you can use Semaphore to limit the # of in-flight.
FuturesUnordered & keep all futures on the same thread

(Commenting because I'm having a similar use case again and I was wondering whether I should use FuturesUnordered ^^)

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

Successfully merging this pull request may close these issues.

3 participants