This repository has been archived by the owner on Oct 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 163
Use tokio instead of async_std #307
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8be75f7
feat: change the async executor to tokio
ljedrz 398aa58
chore: import reordering with cargo fmt
ljedrz 9e26bff
chore: cargo clippy
ljedrz 4001e01
refactor: remove unused tokio features
ljedrz c930f65
test: make async tests use only 1 thread
ljedrz 7ff0a3c
fix: ignore resolve tests due to Windows errors
ljedrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
use async_std::task; | ||
use futures::join; | ||
use ipfs::{make_ipld, Ipfs, TestTypes, UninitializedIpfs}; | ||
use tokio::task; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
tracing_subscriber::fmt::init(); | ||
|
||
task::block_on(async move { | ||
let (ipfs, fut): (Ipfs<TestTypes>, _) = | ||
UninitializedIpfs::default().await.start().await.unwrap(); | ||
task::spawn(fut); | ||
let (ipfs, fut): (Ipfs<TestTypes>, _) = | ||
UninitializedIpfs::default().await.start().await.unwrap(); | ||
task::spawn(fut); | ||
|
||
let f1 = ipfs.put_dag(make_ipld!("block1")); | ||
let f2 = ipfs.put_dag(make_ipld!("block2")); | ||
let (res1, res2) = join!(f1, f2); | ||
let f1 = ipfs.put_dag(make_ipld!("block1")); | ||
let f2 = ipfs.put_dag(make_ipld!("block2")); | ||
let (res1, res2) = join!(f1, f2); | ||
|
||
let root = make_ipld!([res1.unwrap(), res2.unwrap()]); | ||
ipfs.put_dag(root).await.unwrap(); | ||
let root = make_ipld!([res1.unwrap(), res2.unwrap()]); | ||
ipfs.put_dag(root).await.unwrap(); | ||
|
||
ipfs.exit_daemon().await; | ||
}); | ||
ipfs.exit_daemon().await; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
use async_std::task; | ||
use futures::join; | ||
use ipfs::{Ipfs, IpfsPath, TestTypes, UninitializedIpfs}; | ||
use std::str::FromStr; | ||
use tokio::task; | ||
|
||
fn main() { | ||
#[tokio::main] | ||
async fn main() { | ||
tracing_subscriber::fmt::init(); | ||
|
||
let path = | ||
IpfsPath::from_str("/ipfs/zdpuB1caPcm4QNXeegatVfLQ839Lmprd5zosXGwRUBJHwj66X").unwrap(); | ||
|
||
task::block_on(async move { | ||
let (ipfs, fut): (Ipfs<TestTypes>, _) = | ||
UninitializedIpfs::default().await.start().await.unwrap(); | ||
task::spawn(fut); | ||
let (ipfs, fut): (Ipfs<TestTypes>, _) = | ||
UninitializedIpfs::default().await.start().await.unwrap(); | ||
task::spawn(fut); | ||
|
||
let f1 = ipfs.get_dag(path.sub_path("0").unwrap()); | ||
let f2 = ipfs.get_dag(path.sub_path("1").unwrap()); | ||
let (res1, res2) = join!(f1, f2); | ||
println!("Received block with contents: {:?}", res1.unwrap()); | ||
println!("Received block with contents: {:?}", res2.unwrap()); | ||
let f1 = ipfs.get_dag(path.sub_path("0").unwrap()); | ||
let f2 = ipfs.get_dag(path.sub_path("1").unwrap()); | ||
let (res1, res2) = join!(f1, f2); | ||
println!("Received block with contents: {:?}", res1.unwrap()); | ||
println!("Received block with contents: {:?}", res2.unwrap()); | ||
|
||
ipfs.exit_daemon().await; | ||
}); | ||
ipfs.exit_daemon().await; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: soon tokio-mdns as well, mdns might still use async-std by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I was looking at the main features in search for other
tokio
ones and found none -mdns
does useasync-std
right now; probably gonna change soon, like you're saying.