mirror of
https://github.com/Noratrieb/ice-104649.git
synced 2026-01-14 12:35:02 +01:00
delete tokio
This commit is contained in:
parent
9d73254291
commit
a572c048c9
3 changed files with 26 additions and 1045 deletions
1031
Cargo.lock
generated
1031
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -6,6 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.11", features = ["json", "brotli", "gzip", "native-tls", "deflate"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
futures = "0.3.25"
|
||||
|
|
|
|||
38
src/main.rs
38
src/main.rs
|
|
@ -1,18 +1,32 @@
|
|||
use futures::{stream, StreamExt};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use futures::{stream, StreamExt, Future};
|
||||
|
||||
pub struct JoinHandle<T> {
|
||||
raw: Option<()>,
|
||||
id: u64,
|
||||
_p: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T> Future for JoinHandle<T> {
|
||||
type Output = Result<T, ()>;
|
||||
|
||||
fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spawn<T>(future: T) -> JoinHandle<T::Output>
|
||||
where
|
||||
T: Future + Send + 'static,
|
||||
T::Output: Send + 'static,
|
||||
{
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let client = reqwest::Client::builder().build().unwrap();
|
||||
|
||||
// Concurrent Requests
|
||||
let bodies = stream::iter([])
|
||||
.map(|url: String| {
|
||||
let req = client.get(&url);
|
||||
tokio::spawn(async move {
|
||||
let resp = req.send().await.unwrap();
|
||||
let text = resp.text().await.unwrap();
|
||||
Result::Ok((url, text))
|
||||
})
|
||||
})
|
||||
.map(|url: String| spawn(async move { Result::Ok((url, "A".to_owned())) }))
|
||||
.buffer_unordered(0);
|
||||
|
||||
bodies.for_each(|b| async {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue