mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-30 18:34:36 +01:00
export blocking via web module
This commit is contained in:
parent
0e57b4ad61
commit
c2a350b33f
12
src/lib.rs
12
src/lib.rs
@ -77,6 +77,7 @@ pub mod web {
|
|||||||
pub use actix_http::Response as HttpResponse;
|
pub use actix_http::Response as HttpResponse;
|
||||||
pub use bytes::{Bytes, BytesMut};
|
pub use bytes::{Bytes, BytesMut};
|
||||||
|
|
||||||
|
use crate::blocking::CpuFuture;
|
||||||
use crate::extract::FromRequest;
|
use crate::extract::FromRequest;
|
||||||
use crate::handler::{AsyncFactory, Factory};
|
use crate::handler::{AsyncFactory, Factory};
|
||||||
use crate::resource::Resource;
|
use crate::resource::Resource;
|
||||||
@ -234,4 +235,15 @@ pub mod web {
|
|||||||
{
|
{
|
||||||
Route::new().to_async(handler)
|
Route::new().to_async(handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Execute blocking function on a thread pool, returns future that resolves
|
||||||
|
/// to result of the function execution.
|
||||||
|
pub fn blocking<F, I, E>(f: F) -> CpuFuture<I, E>
|
||||||
|
where
|
||||||
|
F: FnOnce() -> Result<I, E> + Send + 'static,
|
||||||
|
I: Send + 'static,
|
||||||
|
E: Send + std::fmt::Debug + 'static,
|
||||||
|
{
|
||||||
|
crate::blocking::run(f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user