mirror of
https://github.com/Noratrieb/icefun.git
synced 2026-01-16 13:45:01 +01:00
loop
This commit is contained in:
parent
44a0230869
commit
dd3b3980bf
2 changed files with 9 additions and 20 deletions
|
|
@ -8,14 +8,13 @@ use crate::rt::Executor;
|
||||||
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
|
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
|
||||||
use crate::server::server::{new_svc::NewSvcTask, Watcher};
|
use crate::server::server::{new_svc::NewSvcTask, Watcher};
|
||||||
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
|
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
|
||||||
use crate::service::HttpService;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
pub trait ConnStreamExec<F, B: HttpBody>: Clone {
|
pub trait ConnStreamExec<F, B>: Clone {
|
||||||
fn execute_h2stream(&mut self, fut: H2Stream<F, B>);
|
fn execute_h2stream(&mut self);
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
|
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
|
||||||
pub trait NewSvcExec<I, S, E, W: Watcher<I, S, E>>: Clone {
|
pub trait NewSvcExec<I, S, E, W: Watcher<I, S, E>>: Clone {
|
||||||
|
|
@ -39,7 +38,7 @@ where
|
||||||
H2Stream<F, B>: Future<Output = ()> + Send + 'static,
|
H2Stream<F, B>: Future<Output = ()> + Send + 'static,
|
||||||
B: HttpBody,
|
B: HttpBody,
|
||||||
{
|
{
|
||||||
fn execute_h2stream(&mut self, fut: H2Stream<F, B>) {
|
fn execute_h2stream(&mut self) {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +47,6 @@ where
|
||||||
impl<I, S, E, W> NewSvcExec<I, S, E, W> for Exec
|
impl<I, S, E, W> NewSvcExec<I, S, E, W> for Exec
|
||||||
where
|
where
|
||||||
NewSvcTask<I, S, E, W>: Future<Output = ()> + Send + 'static,
|
NewSvcTask<I, S, E, W>: Future<Output = ()> + Send + 'static,
|
||||||
S: HttpService<Body>,
|
|
||||||
W: Watcher<I, S, E>,
|
W: Watcher<I, S, E>,
|
||||||
{
|
{
|
||||||
fn execute_new_svc(&mut self, fut: NewSvcTask<I, S, E, W>) {
|
fn execute_new_svc(&mut self, fut: NewSvcTask<I, S, E, W>) {
|
||||||
|
|
@ -62,7 +60,7 @@ where
|
||||||
H2Stream<F, B>: Future<Output = ()>,
|
H2Stream<F, B>: Future<Output = ()>,
|
||||||
B: HttpBody,
|
B: HttpBody,
|
||||||
{
|
{
|
||||||
fn execute_h2stream(&mut self, fut: H2Stream<F, B>) {
|
fn execute_h2stream(&mut self) {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ impl<I, E> Builder<I, E> {
|
||||||
}
|
}
|
||||||
pub trait Watcher<I, S, E>: Clone {
|
pub trait Watcher<I, S, E>: Clone {
|
||||||
type Future;
|
type Future;
|
||||||
fn watch(&self) -> Self::Future;
|
|
||||||
}
|
}
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
|
@ -89,39 +88,31 @@ where
|
||||||
S: HttpService<Body>,
|
S: HttpService<Body>,
|
||||||
{
|
{
|
||||||
type Future = ();
|
type Future = ();
|
||||||
fn watch(&self) -> Self::Future {
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub(crate) mod new_svc {
|
pub(crate) mod new_svc {
|
||||||
use super::Watcher;
|
use super::Watcher;
|
||||||
use crate::body::{Body, HttpBody};
|
use crate::body::{Body, HttpBody};
|
||||||
use crate::common::exec::ConnStreamExec;
|
use crate::common::exec::ConnStreamExec;
|
||||||
use crate::common::{task, Future, Pin, Poll, Unpin};
|
use crate::common::{task, Future, Pin, Poll};
|
||||||
use crate::service::HttpService;
|
use crate::service::HttpService;
|
||||||
use std::error::Error as StdError;
|
|
||||||
use tokio::io::{AsyncRead, AsyncWrite};
|
|
||||||
|
|
||||||
pub struct NewSvcTask<I, S, E, W: Watcher<I, S, E>> {
|
pub struct NewSvcTask<I, S, E, W: Watcher<I, S, E>> {
|
||||||
state: State<I, S, E, W>,
|
state: State<I, S, E, W>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) enum State<I, S, E, W: Watcher<I, S, E>> {
|
pub(super) struct State<I, S, E, W: Watcher<I, S, E>> {
|
||||||
Connecting { a: (I, S, W, E) },
|
a: (I, S, E),
|
||||||
|
future: W::Future,
|
||||||
Connected { future: W::Future },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I, S: HttpService<Body>, E, W: Watcher<I, S, E>> NewSvcTask<I, S, E, W> {
|
impl<I, S: HttpService<Body>, E, W: Watcher<I, S, E>> NewSvcTask<I, S, E, W> {
|
||||||
pub(super) fn new(watcher: W) -> Self {
|
pub(super) fn new(_: W) -> Self {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<I, S, B, E, W> Future for NewSvcTask<I, S, E, W>
|
impl<I, S, B, E, W> Future for NewSvcTask<I, S, E, W>
|
||||||
where
|
where
|
||||||
S: HttpService<Body, ResBody = B>,
|
S: HttpService<Body, ResBody = B>,
|
||||||
B: HttpBody + 'static,
|
|
||||||
B::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
||||||
E: ConnStreamExec<S::Future, B>,
|
E: ConnStreamExec<S::Future, B>,
|
||||||
W: Watcher<I, S, E>,
|
W: Watcher<I, S, E>,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue