mirror of
https://github.com/Noratrieb/ice-104649.git
synced 2026-01-16 13:25:03 +01:00
delete tokio
This commit is contained in:
parent
9d73254291
commit
a572c048c9
3 changed files with 26 additions and 1045 deletions
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