Open SylvainGarrigues opened 1 year ago
I don't remember if the Send trait is needed. I assume it was added to make something else happy, if you wanted to try to remove it and see if the library still compiles...
I feel like it was introduced at that time: https://github.com/seanmonstar/warp/commit/79ead366582e1df67208c59dadf1a6a2e1475eee#diff-ff6d351d5b8e9ccd8131a2368e902858310c79aa975f2ed11fd53c6b7da68817
Also the AndThen filter has the same Send requirement so I guess relaxing the Send trait only for Map won't help much :(
I don't remember if the Send trait is needed. I assume it was added to make something else happy, if you wanted to try to remove it and see if the library still compiles...
I had to remove + Send
all around the place and even disable some code (e.g. warp server stuff) to make it compile without Send, so I am enclines to say there is no easy way to use warp with a single-threaded executor and a !Send
state.
I'm am running warp as a service with a single-threaded hyper server.
The setup is based on: https://github.com/hyperium/hyper/blob/0.14.x/examples/single_threaded.rs
which allows to use a state shared through an Rc pointer.
I am trying to port the warp todos example in this setup, with an Rc/Refcell because Arc is not needed, and I cannot because this line: https://github.com/seanmonstar/warp/blob/4e9c4fd6ce238197fd1088061bbc07fa2852cb0f/examples/todos.rs#L100
creates a Map filter which does not implement warp::filter::FilterBase, because warp's implementation requires to use Send closures:
(see the Send trait on the last line - taken from https://github.com/seanmonstar/warp/blob/master/src/filter/map.rs).
It is so frustrating to use sync primitives (Arc / Mutex) when they are not needed!
Is there any workaround? Is the Send trait necessary there?